Re: Overriding -dealloc on any object

2009-03-25 Thread Keary Suska

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.


HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Overriding -dealloc on any object

2009-03-25 Thread Ryan Joseph
I'm working on a Cocoa bridge for Pascal and looking for a solution to  
manage the wrapper objects that are directly related to all their  
Objective-C counterparts, and therefore must be released in pairs. I  
understand that -dealloc is the designated location to release  
instances owned by the object so the plan is to override -dealloc on  
any object that a wrapper is allocated for.


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!


Regards,
Josef

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com