Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [MagicalRecord saveInBackgroundWithBlock:^(NSManagedObjectContext *localContext) {
- // Do this hundreds of times
- [MyObject createInContext:localContext];
- }];
- [MagicalRecord saveInBackgroundWithBlock:^(NSManagedObjectContext *localContext) {
- // Do this hundreds of times
- [MyObject createInContext:localContext];
- } completion:^{
- [[NSOperationQueue mainQueue] addOperationWithBlock:^{
- [[NSManagedObjectContext defaultContext] saveNestedContexts];
- }];
- }];
- self.queue = [[NSOperationQueue alloc] init];
- [self.queue addOperationWithBlock:^{
- NSManagedObjectContext *localContext = [NSManagedObjectContext contextForCurrentThread];
- // Do this hundreds of times
- [MyObject createInContext:localContext];
- [localContext saveNestedContexts];
- }];
- dispatch_queue_t syncQueue = dispatch_queue_create("Sync queue", NULL);
- dispatch_async(syncQueue, ^{
- NSManagedObjectContext *localContext = [NSManagedObjectContext contextForCurrentThread];
- // Do this hundreds of times
- [MyObject createInContext:localContext];
- [[NSManagedObjectContext contextForCurrentThread] saveNestedContexts];
- });
Add Comment
Please, Sign In to add comment