• 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: Releasing what's in an array?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Releasing what's in an array?


  • Subject: Re: Releasing what's in an array?
  • From: Andy Armstrong <email@hidden>
  • Date: Fri, 25 Feb 2005 19:47:07 +0000

On 25 Feb 2005, at 19:35, Charlton Wilbur wrote:
If you have an object you did allocate, it's often wise to release it after adding it to the array and then later retain it if you want to remove it from the array - it's simpler to match an alloc/release around adding it to the array and a retain/release around removing it from the array than it is to match an alloc around adding it to the array with a release around removing it from the array; in particular, you know when you allocate or otherwise obtain the object whether you need to release it, while you might not know that when you remove it from the array.

(I know you're not suggesting otherwise Charlton - just clarifying)

If you do that though you must retain the object /before/ removing it from the array otherwise you will end up trying to retain an object that has already been deallocated.

--
Andy Armstrong, hexten.net

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Releasing what's in an array? (From: Mark Dawson <email@hidden>)
 >Re: Releasing what's in an array? (From: Shawn Erickson <email@hidden>)
 >Re: Releasing what's in an array? (From: Mark Dawson <email@hidden>)
 >Re: Releasing what's in an array? (From: Shawn Erickson <email@hidden>)
 >Re: Releasing what's in an array? (From: Mark Dawson <email@hidden>)
 >Re: Releasing what's in an array? (From: Charlton Wilbur <email@hidden>)

  • Prev by Date: Re: Releasing what's in an array?
  • Next by Date: Re: Releasing what's in an array?
  • Previous by thread: Re: Releasing what's in an array?
  • Next by thread: Re: Releasing what's in an array?
  • Index(es):
    • Date
    • Thread