• 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: retain/release question about Apple docs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: retain/release question about Apple docs


  • Subject: Re: retain/release question about Apple docs
  • From: "Clark Cox" <email@hidden>
  • Date: Mon, 6 Mar 2006 14:13:26 -0500

On 3/6/06, Julian Cain <email@hidden> wrote:
> Correct, i am assuming that i never set a value to nil, in which case
> i never really need to so far, otherwise i would use a normal retain/
> release. I assume changing my macro to #define REPLACE(a, b)    if (b !=
> a) {[b retain]; [a release]; a = b;}    might be safer?

Even better would be:

#define REPLACE(a, b) do { if (b != a) {[b retain]; [a release]; a =
b; } } while(0)

Think about what happens if it is called like the following:

if(flag)
  REPLACE(foo, bar);
else
  REPLACE(foo, baz);

--
Clark S. Cox III
email@hidden
My CV/Resume:
http://homepage.mac.com/clarkcox3/files/Resume.pdf
http://homepage.mac.com/clarkcox3/files/Resume.html
 _______________________________________________
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

  • Follow-Ups:
    • Re: retain/release question about Apple docs
      • From: Shaun Wexler <email@hidden>
References: 
 >retain/release question about Apple docs (From: "James W. Walker" <email@hidden>)
 >Re: retain/release question about Apple docs (From: Volker Runkel <email@hidden>)
 >Re: retain/release question about Apple docs (From: Julian Cain <email@hidden>)
 >Re: retain/release question about Apple docs (From: Greg Titus <email@hidden>)
 >Re: retain/release question about Apple docs (From: Julian Cain <email@hidden>)

  • Prev by Date: Re: Text Layout problems
  • Next by Date: Re: NSArrayController's contentArray and selectedIndexes don't match when sorted
  • Previous by thread: Re: retain/release question about Apple docs
  • Next by thread: Re: retain/release question about Apple docs
  • Index(es):
    • Date
    • Thread