Re: NS_INLINE and obj = nil;?
Re: NS_INLINE and obj = nil;?
- Subject: Re: NS_INLINE and obj = nil;?
- From: "Stephen J. Butler" <email@hidden>
- Date: Fri, 1 Jan 2010 22:09:09 -0600
On Fri, Jan 1, 2010 at 10:01 PM, aaron smith
<email@hidden> wrote:
> Hey All, quick question,
>
> I wrote a simple macro to make memory cleanup a bit easier, but I ran
> into something I'm not sure why is happening..
>
> here's the macro:
>
> NS_INLINE void GDRelease(id obj) {
> [obj release];
> obj=nil;
> }
That's not a macro, it's an inlined function. The reason the nil
doesn't work is for the same reason it wouldn't work in any other
function. Namely, you're only modifying the argument (which is a copy)
and not the original variable. If you really wanted a macro, it would
look like this:
#define GDRelease(x) do { [(x) release]; (x) = nil; } while (0)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden