开发者

objC three20 example ttnavigator menu controller page instance declaration

I tried to understand the three20 ttnavigator example code, and in the MenuController.h file, it is as follows:

typedef enum {
  MenuPageNone,
  MenuPageBreakfast,
  MenuPageLunch,
  MenuPageDinner,
  MenuPageDessert,
  MenuPageAbout,
} MenuPage;

@interface MenuController : TTTableViewController {
  MenuPage _page;
}

@property(nonatomic) MenuPage page;

@end

I don't understand why there is a MenuPage _page declared as an instance variable, while there is another variable MenuPage page declared in the @property section. In the MenuController.m file, MenuPage page is synthesized, not _page.

Is this legal?

I know it works, because 开发者_如何学JAVAit compiles, but I don't understand why we don't need to set an @property (nonatomic, retain) MenuPage _page or declare MenuPage page in the interface.

Thanks!


This line in MenuController.m

@synthesize page = _page;

connects the property to the ivar. (It tells the compiler to use the _page ivar to store the value of the page property.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜