Hi All, This is a bit dodgy so bear with me.
I have a class that is a subclass of a third party framework. This is hard to explain, but I’m trying to make it into a singleton of kinds. When the framework wants an object of this particular class it alloc/init’s a new one. This calls the designated initializer. I have overridden this initializer and want to pass back a version of the object that has already been allocated and has a retainCount of at least +1. I know that when the object is returned to the caller inside the framework it is going to be autoreleased. In my override I do this: -(instancetype) initWithID:(NSString*) something { NSString* myID; id myNewObject; id myCachedObject; myNewObject = [super initWithSomething: something]; if (myNewObject == nil) return nil; myID = [self getID]; myCachedObject = [LTWCacheManager getObjectForID: myID]; if ( myCachedObject == nil); { self = myNewObject; [LTWCacheManager addToCache: myID]; return self; } [myNewObject release]; [myCachedObject retain]; //Added this Badness but it makes no difference. self = myCachedObject; return self; } Now when the (one) Cached object is (finally) released it crashes……. It gets autoreleased after this method returns. Other then crashing when it is dealloc’ed, it seems to work ok. I know the above is dodgy but its a work around and I’m wondering if I can do something like this as an interim fix to get my past a hurdle? Thanks in Advance, All the Best Dave PS Don’t worry, I’ve sacrificed the correct number of chickens to be protected from the curse of this hack! lol _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com