Re: iOS Pass NSManagedObjectContext from my app delegate
Re: iOS Pass NSManagedObjectContext from my app delegate
- Subject: Re: iOS Pass NSManagedObjectContext from my app delegate
- From: Eeyore <email@hidden>
- Date: Thu, 20 Jan 2011 17:04:23 -0800
On Jan 20, 2011, at 4:46 PM, Nick Zitzmann wrote:
>
> On Jan 20, 2011, at 5:25 PM, Philip Vallone wrote:
>
>> Currently, my NSManagedObjectContext is retained like this in my app delegate:
>>
>> @property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;
>
> If you have declared the property to be read-only, then the retain keyword is not necessary. Retain and assign are only necessary if it's a read/write property, since they tell the synthesizer what to do with new values (if @synthesize is in use).
I'm somewhat new to all this also, so perhaps I'm off on this one. My understanding is that using (retain, readonly) in the class interface insures that if the property is ever changed to readwrite in a category, then it must be (retain, readwrite) and not (assign, readwrite) or (copy, readwrite). Whether this guarantee is important or not probably depends on the circumstances, but there is extra information the compiler can use to catch errors when you declare it as (retain, readonly) that isn't available when you declare it as (readonly).
Aaron
_______________________________________________
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