Re: NSPrivateQueueConcurrencyType working outside of performBlock
Re: NSPrivateQueueConcurrencyType working outside of performBlock
- Subject: Re: NSPrivateQueueConcurrencyType working outside of performBlock
- From: Trygve Inda <email@hidden>
- Date: Tue, 28 Jul 2015 20:49:47 -0700
- Thread-topic: NSPrivateQueueConcurrencyType working outside of performBlock
>
>> On 28 Jul 2015, at 9:12 pm, Trygve Inda <email@hidden> wrote:
>>
>> I gather that when using NSPrivateQueueConcurrencyType, all operations (a
>> fetch for example) have to be done within a performBlock call.
>>
>
> ...
>
>> Then later, this context is used outside a performBlock:
>>
>>
>> NSArray *matchingQuakes = [taskContext
>> executeFetchRequest:matchingQuakeRequest error:&anyError];
>>
>>
>> Why does this work?
>
> You are supposed to call performBlock so that all accesses to the MOC are
> serialized on the queue and so you get thread safety that way.
So what has to be called though performBlock??
NSManagedObjectContext* privateContext = [[NSManagedObjectContext alloc]
initWithConcurrencyType:NSPrivateQueueConcurrencyType];
// Are these legal to call without using performBlock?
[privateContext setPersistentStoreCoordinator:myCoordinator];
[privateContext setUndoManager:nil];
_______________________________________________
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