Note that there are some explanatory texts on larger screens.

plurals
  1. POCocoa Interface Style
    text
    copied!<p>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 <em>why</em> 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 <em>some</em> 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):</p> <pre><code>@interface AViewController : UIViewController &lt;UITextViewDelegate&gt; { @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) &lt;UITableViewDelegate, UITableViewDataSource&gt; @end </code></pre> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload