Re: Declaring Variables - Setting to nil VS Not Setting?
Re: Declaring Variables - Setting to nil VS Not Setting?
- Subject: Re: Declaring Variables - Setting to nil VS Not Setting?
- From: Sean McBride <email@hidden>
- Date: Thu, 26 Apr 2012 16:34:12 -0400
>I usually use the sample in line 1 when declaring vars inside my methods.
>
>NSString *theString = [NSString string];
>NSString *theString = nil;
>NSString *theString;
>
>I thought lines 2 and 3 were the same thing. I was wrong. What is the
>difference and when do you use the style shown in line 3?
Fritz is spot on. In addition, note that forms 2 and 3 are only the same under the ARC memory model, and is only the case for pointers to Obj-C objects. This is a very new change to Obj-C.
Sean
_______________________________________________
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