Subject: Re: Overriding -dealloc on any object
On Mar 25, 2009, at 7:29 AM, Ryan Joseph wrote:
The question is, will it be safe to override methods like
initWithObjects: that are owned by Cocoa and created through
convenience functions? Will those objects be sent -dealloc also?
Second, given the Objective-C runtime should I replace the
implementation using class_replaceMethod or do I need to add a new
method using class_addMethod? I did observe that -dealloc does
indeed have an implementation so I'm not sure class_addMethod will
even have any affect, but I'm not sure replace the implementation is
safe either. Any help is appreciated. Thanks!
I am not entirely certain I am following you but to work with Cocoa
(in a non-GC environment) you will need to follow (and expect all
Cocoa objects to follow) the Memory Management Guidelines. This
document will tell you most, if not all, you need to know about memory
management in Cocoa.
If you need to essentially override -dealloc that will be inherited by
all objects, well, that's tricky, and requires some knowledge and use
if Obj-C runtime functions. Beyond me. But then, do you really need
that? I don't know what is involved in creating these "bridges", but
it seems saner to me to maintain your own set of "manager" objects
that then control native Cocoa objects.
"Demystifying technology for your home or business"
Cocoa-dev mailing list (Cocoa-dev@xxxxxxxxxxxxxxx)
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 maillists@xxxxxxxxx