• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Toolbar code in separate Controller?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Toolbar code in separate Controller?


  • Subject: Re: Toolbar code in separate Controller?
  • From: Graham Cox <email@hidden>
  • Date: Tue, 15 Jul 2008 23:33:04 +1000


On 15 Jul 2008, at 11:13 pm, John Love wrote:

To tell you the truth, I *really* prefer calling a category an extension because "extension" just sounds more meaningful to me. Or, maybe just plain, ole, generic "addition". "Category" just sounds like "type of" or a sub-class, but it's not that at all.

Well, the Cocoa terminology is 'Category', whether that is the normal plain-English meaning or not. So it's really a good idea to stick to using the term 'Category' within the context of Cocoa jargon to mean this, otherwise no-one else will have the foggiest idea what you're talking about.


Back to NSToolbarItemValidation .. it is not a "type of" MyDocument. So, based on the above, I should not call it a "category" of MyDocument. So what do I call it? Is it an "extension" of MyDocument?

No, it's a category on MyDocument.


Apple states " NSToolbarItemValidation extends the standard validation idea ..". In Apple's Objective-C pdf, Apple sttates "Class extensions are like 'anonymous' categories ..".


I've reached a road block here .. Apple says "extends the standard validation idea", yet:
@interface MyDocument (NSToolbarItemValidation)
implies that NSToolbarItemValidation extends MyDocument.


I stand at a road block .. would appreciate some help here!


Well, what are you asking? Does the code work or not? If not, what are the symptoms?

NSToolbarItemValidation is an informal protocol. It's declared as a category on NSObject, which is conventional for informal protocols. It's the same concept I went over for your delegate callback. If your document implements it and it's hooked up correctly to the toolbar, your validation method should be called. Whether you place this in a category of your own or not is really of no relevance. Personally if I'm implementing standard protocols I usually put them in the main file (i.e in MyDocument.m) since they are easier to find there, and you've already subclassed NSDocument to create MyDocument, so creating additional categories is a bit pointless, IMHO. Sure, if your code for this class ends up huge and needs breaking up for sanity's sake, by all means parcel off stuff into categories, but at this stage I believe you are confusing yourself by introducing too many concepts just for the sake of it, without getting a more straightforward and basic set-up working.


Graham


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Toolbar code in separate Controller?
      • From: "John Love" <email@hidden>
    • Re: Toolbar code in separate Controller?
      • From: Graham Cox <email@hidden>
References: 
 >Toolbar code in separate Controller? (From: "John Love" <email@hidden>)
 >Re: Toolbar code in separate Controller? (From: Uli Kusterer <email@hidden>)
 >Re: Toolbar code in separate Controller? (From: "John Love" <email@hidden>)
 >Re: Toolbar code in separate Controller? (From: Graham Cox <email@hidden>)
 >Re: Toolbar code in separate Controller? (From: "John Love" <email@hidden>)

  • Prev by Date: IBPlugin cannot load
  • Next by Date: Re: Toolbar code in separate Controller?
  • Previous by thread: Re: Toolbar code in separate Controller?
  • Next by thread: Re: Toolbar code in separate Controller?
  • Index(es):
    • Date
    • Thread