• 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: Category or Protocol? (sidetrack)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Category or Protocol? (sidetrack)


  • Subject: RE: Category or Protocol? (sidetrack)
  • From: Jeff Laing <email@hidden>
  • Date: Thu, 21 Apr 2005 14:12:12 +1000

> > Ok, this is something that really hadn't occurred to me. I've been
> > operating
> > under the assumption that categories are something that you do to
> > "someone
> > elses classes".
> >
>
> "Categories can also be used to distribute the implementation of a
> new class into separate source files—for example, you could
> group the
> methods of a large class into several categories and put each
> category in a different file. When used like this, categories can
> benefit the development process in a number of ways:"
>
>
<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Langua
geOverview/chapter_3_section_7.html>

... the section entitied "Extending Classes", which a big bold heading
saying"Categories: Adding Methods to Existing Classes", which didn't sound
all that relevant and I confess I only read the first section before
thinking "I know how this works" and skipped to "Protocols:

Eh, I'm just making excuses, I should have read it all rather than skimming
headings.  Then again, who ever read Stroustrop from cover to cover?  Or
K&R?

Having said that, lets get back to the "best practice" part of the
discussion.

If I have myclass which is going to act as a delegate to some other object,
do the Obj-C gurus here suggest that its good/bad/indifferent style to
compartmentalise the corresponding delegate methods into a category?

Are there sneaky runtime characteristics that I'm going to invoke that I, as
novice, can't see? I dunno, I might preclude people from doing isa swizzling
on my classes, something like that?  No idea why that would happen, but
thats why I'm asking experts!

I can see where it wouldnt be too difficult to write a Q&D yacc grammar that
I fed "myclass.h" into and it pumped out a "myclass-accessors.h" file that
contained all the standard accessor methods in a category called
myclass(MyAccessors) ?

(I believe that Accessorizer does something like this, but I'm of the
understanding that its GUI based, not designed to be wired into a
makefile/xcode build.  Or perhaps it is?)

But would it be "a bad thing(tm)" to push all my accessor methods out into a
category?  And if so, why?
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Category or Protocol? (sidetrack)
      • From: mmalcolm crawford <email@hidden>
    • Re: Category or Protocol? (sidetrack)
      • From: Justin Spahr-Summers <email@hidden>
  • Prev by Date: Re: OT: Which list to ask SearchKit usage questions?
  • Next by Date: Re: modifying class initalisation
  • Previous by thread: Re: Category or Protocol? (sidetrack)
  • Next by thread: Re: Category or Protocol? (sidetrack)
  • Index(es):
    • Date
    • Thread