Having an NSManagedObjectContext
with concurrency type NSPrivateQueueConcurrencyType
can PromiseKit be used to prettify the performBlock:^{}
/ performBlockAndWait:^{}
?
My first thought was to write like this :
- (PMKPromise *)updateModel:(Model *)model
{
return [PMKPromise new:^(PMKPromiseFulfiller fulfill, PMKPromiseRejecter reject) {
[_managedContenxtModel performBlock:^{
//...
fulfill(...)
}];
}];
}
but, I'm afraid that because the promise block will be registered in a DISPATCH_QUEUE_CONCURRENT
and if multiple calls to updateModel:
, from different threads, are made it can't guarantee that the blocks from the performBlock
are registered in the correct order.
Is there a change that this can happen ?
What about using performBlockAndWait:^{}
instead ?