Re: Notifications with an autoreleased object?
Re: Notifications with an autoreleased object?
- Subject: Re: Notifications with an autoreleased object?
- From: Andy Lee <email@hidden>
- Date: Sun, 7 Apr 2002 09:56:22 -0400
At 7:13 PM -0500 4/6/02, Rich Long wrote:
I am posting some notifications with an object that has been
autoreleased (as, for example, [postNotificationName: foo object:
autoreleased-obj]). This seems to work fine, but is it OK?
My understanding of autorelease objects is that they go away at the
end of the current event handler
Not quite. Autorelease objects have their *retain count* decremented
at the end of the current iteration of the event loop. Objects are
deallocated when their retain count goes to zero. So if the object
had a retain count of 1, then indeed it will be deallocated when the
retain count goes down to 0. But if it had been sent one or more
-retain messages, it wouldn't be deallocated until enough -release
and/or -autorelease messages had been sent to bring the retain count
down to 0.
--Andy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.