Re: retain/release question about Apple docs
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