Re: [moderator] Re: swizzling a class to a subclass inorder to add ivars (& methods) to a class
Re: [moderator] Re: swizzling a class to a subclass inorder to add ivars (& methods) to a class
- Subject: Re: [moderator] Re: swizzling a class to a subclass inorder to add ivars (& methods) to a class
- From: John Stiles <email@hidden>
- Date: Mon, 30 Oct 2006 13:58:56 -0800
On Oct 30, 2006, at 1:22 PM, Scott Morrison wrote:
Apart from all the WWDC NDA stuff -- (which is pretty hard to miss
considering they have that on every opening slide of each
presentation, and was in reminders all over Moscone) Lets get
back to the original question.....
Is it OK to swizzle the alloc method to return an allocated
subclass rather than the superclass that was whose allocation was
requested. What are problems associated with this? -- Yes -- there
may be hidden implementation stuff that you are mucking about it.
but if you know the classes involved -- is there a problem?
From what I seen of some things (from google searches), this is
done in a variety of situations (eg [NSDictionary alloc] to return
different private implementations depending on a variety of
situations)
I am pretty sure this is a common occurrence in AppKit/Cocoa;
NSString does it too.
Other than the fact that introspection will return results that you
might not have expected, it probably isn't a problem. (e.g. if you
have code which checks the class name of an object to determine its
behavior, that code might break.)
_______________________________________________
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