I'm on a project doing an iPhone application. We had a Cocoa consultant come in for a few weeks. He showed me an interesting idiom of Cocoa, dealing with interfaces, but there was a difficult language barrier between us, and he wasn't really able to explain why this was done or where it was documented so I could learn more on my own. I went into monkey see mode, and just used the style he prefers. But it's been bugging the hell out of me that I don't know more about the history of this style. It's certainly NOT an informal protocol. Sure enough, looking at some of the Cocoa API headers, I sometimes see the style he asserted was the 'Cocoa' way. Here's an example (note accessors, mutators, etc., each have their own interface declaration without the funny braces):
@interface AViewController : UIViewController <UITextViewDelegate> {
@public
UITableView *tableView;
@private
NSUInteger someIndex;
}
@property (nonatomic, retain) ...
@end
@interface AViewController (AViewControllerCreation)
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil withController:(id)controller;
@end
@interface AViewController (AViewControllerMutator)
- (void) doSomeSettingStuff;
@end
@interface AViewController (AViewControllerAccessor)
- (NSString *)doSomeAccessorStuff;
@end
@interface AViewController (AViewControllerAction)
- (IBAction)cancel:(id)sender;
@end
@interface AViewController (AViewControllerTableViewDelegate) <UITableViewDelegate, UITableViewDataSource>
@end
You can see this style of setting up the interface in NSButton, NSControl, etc. Interestingly, corresponding classes like UIButton, UIControl DON'T use this idiom. Hmm, these probably came after as I assume UIKit was done after AppKit. So is this idiom 'old hat'? Also, is there any reason for it other then style? Is it good style? Bad? Any docs that go over this? Thanks all.