Re: Category or Protocol? (sidetrack)
Re: Category or Protocol? (sidetrack)
- Subject: Re: Category or Protocol? (sidetrack)
- From: Justin Spahr-Summers <email@hidden>
- Date: Thu, 21 Apr 2005 00:15:47 -0500
Category methods are loaded into memory on top of the existing
classes' at runtime. I don't know how this will affect usage compared
to something that's implemented right in the class.
On 4/20/05, Jeff Laing <email@hidden> wrote:
> > > 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