开发者

PageControl example code for the iPhone notation question

I'm looking through the PageControl example from Apple. They have a class called ContentController. In a subclass of the class, PhoneContentController.m, they have this:

@interface ContentController (开发者_如何转开发PrivateMethods)
- (void)loadScrollViewWithPage:(int)page;
- (void)scrollViewDidScroll:(UIScrollView *)sender;
@end

Is this adding a category to the class ContentController?

Why would they put it in this file, versus the original file they created?

By declaring it in the PhoneContentController.m file, does it give this class access without having any additional directives for the compiler?

(I'm trying to understand the OOAD principles and why Apple does certain things in their example code, hierarchies, etc). Thanks!


Is this adding a category to the class ContentController?

Yes, they are adding a category.

Why would they put it in this file, versus the original file they created?

If I recall correctly, this is done because there are two UIs, (one for iPad and one for iPhone,) so that they can write the code only once and use the same handlers in the different view controllers.

By declaring it in the PhoneContentController.m file, does it give this class access without having any additional directives for the compiler?

Well, yes. It's a small matter to compile an additional 4 line file, and I think this is a template related decision rather than a compiler related one. It's simpler to distribute, say, 3 sample files instead of 4, for example.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜