• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSPrivateQueueConcurrencyType working outside of performBlock
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPrivateQueueConcurrencyType working outside of performBlock


  • Subject: NSPrivateQueueConcurrencyType working outside of performBlock
  • From: Trygve Inda <email@hidden>
  • Date: Tue, 28 Jul 2015 06:12:40 -0700
  • Thread-topic: NSPrivateQueueConcurrencyType working outside of performBlock

I gather that when using NSPrivateQueueConcurrencyType, all operations (a
fetch for example) have to be done within a performBlock call.

Apple has sample code here:

https://developer.apple.com/library/mac/samplecode/Earthquakes/History/Histo
ry.html#//apple_ref/doc/uid/TP40014547-RevisionHistory-DontLinkElementID_1

That gets a private queue with:

NSManagedObjectContext *privateQueueContext(NSError *__autoreleasing *error)
{

NSPersistentStoreCoordinator *localCoordinator =
[[NSPersistentStoreCoordinator alloc]
initWithManagedObjectModel:[AAPLCoreDataStackManager
sharedManager].managedObjectModel];

if (![localCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil URL:[AAPLCoreDataStackManager sharedManager].storeURL
options:nil error:error])
        return nil;

NSManagedObjectContext *context = [[NSManagedObjectContext alloc]
initWithConcurrencyType:NSPrivateQueueConcurrencyType];

[context setPersistentStoreCoordinator:localCoordinator];
context.undoManager = nil;

return context;
}


Then later, this context is used outside a performBlock:


NSArray *matchingQuakes = [taskContext
executeFetchRequest:matchingQuakeRequest error:&anyError];


Why does this work?

Trygve



_______________________________________________

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


  • Follow-Ups:
    • Re: NSPrivateQueueConcurrencyType working outside of performBlock
      • From: Roland King <email@hidden>
  • Prev by Date: Change window.rootViewController at runtime
  • Next by Date: Re: NSPrivateQueueConcurrencyType working outside of performBlock
  • Previous by thread: Change window.rootViewController at runtime
  • Next by thread: Re: NSPrivateQueueConcurrencyType working outside of performBlock
  • Index(es):
    • Date
    • Thread