Re: Question about categories
Re: Question about categories
- Subject: Re: Question about categories
- From: Uli Kusterer <email@hidden>
- Date: Sun, 3 Sep 2006 09:45:26 +0200
Am 02.09.2006 um 23:12 schrieb Alan Smith:
I'm making a category on a class and want to add onto the classes
designated initializer method.
I tried overriding it but then I can't use something like this:
if (self = [self init...)
Because that would create an endless loop.
Exactly. Also, ObjC doesn't give any guarantees in what order the
categories will be slapped onto a class, so you can get lots of
entertaining behaviour trying something like this ;-)
My guess is that this is "basic" and that all of you will flip out on
me, saying I should RTFM or that I lack the basic knowledge and would
"benefit" from reading up on my Obj-C. Well, if I knew where to look
for the answer to this I wouldn't be asking here and, isn't the point
of this list to get help?
Sure, but not for questions that can be answered by typing a
sensible description of the problem in a google search field and
hitting return.
HOWEVER, this isn't one of those cases. While you *could* probably
find the answer somewhere on the CocoaDev.com Wiki, it's not really
obvious: To do what you want, you'll have to subclass the class which
you want to change, then call poseAsClass: to make your new subclass
pretend it was the original superclass. That way, all clients of the
code will use your class, but the original class will still be around
to call through to.
Depending on what class you're overriding, caveats on overriding
class clusters and similar stuff may apply.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
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