Re: Memory allocation questions
- (void)setMainSprocket:(Sprocket *)newSprocket { [mainSprocket autorelease]; mainSprocket = [newSprocket retain]; /* Claim the new Sprocket. */ return; } You could, Caveat. You could not. I don't know why they choose to do it that way For newSprocket might be the same object as mainSprocket, and it might have a retain count of one, in which case you'd dealloc it first and use afterwards, with all the potential havoc. Even if mainSprocket and newSprocket are the same object, this could should not cause problems. By autoreleaseing, not releasing, mainSprocket, it might not get dealloc'd, An object does not get dealloc'd until it's reference count is zero. If they are the same object, at the end of the eventLoop, it's ref count will remain the the same as before this method was called. Roarke Lynch ------------------------------- rlynchba@earthlink.net _______________________________________________ cocoa-dev mailing list | cocoa-dev@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev Do not post admin requests to the list. They will be ignored.
participants (1)
-
Roarke Lynch