Re: Retain count in non ARC
Re: Retain count in non ARC
- Subject: Re: Retain count in non ARC
- From: Ken Thomases <email@hidden>
- Date: Sun, 06 Apr 2014 22:25:34 -0500
On Apr 6, 2014, at 9:18 PM, Graham Cox wrote:
> On 7 Apr 2014, at 10:35 am, Varun Chandramohan <email@hidden> wrote:
>
>> @property (retain) NSArray* contents;
>
> Should be:
>
> @property (copy) NSArray* contents;
> @synthesize contents = ivarContents;
>
> Having done that you'll now only have one ivar, the one you declared, and it will be associated with the property 'contents'. You won't need to write your own getter, but the setter should look something like:
Be careful. If the property is atomic (i.e. not declared nonatomic) and you implement any of the accessors, then you have to implement them all to ensure they use the same synchronization scheme to achieve atomicity. Usually, it's better/easier to simply declare the property nonatomic.
Regards,
Ken
_______________________________________________
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