• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Notifications with an autoreleased object?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Notifications with an autoreleased object? (From: Rich Long <email@hidden>)

  • Prev by Date: Re: Color entire table view row
  • Next by Date: performance of NSBezierPath
  • Previous by thread: Re: Notifications with an autoreleased object?
  • Next by thread: Re: Why does PB look in ~/Developer for ProjectBuilder Extras?
  • Index(es):
    • Date
    • Thread