Skip to content

Instantly share code, notes, and snippets.

@rizumita
Last active August 29, 2015 13:58
Show Gist options
  • Save rizumita/10333688 to your computer and use it in GitHub Desktop.
Save rizumita/10333688 to your computer and use it in GitHub Desktop.
Using ReactiveCoreData with NSBlockOperation
NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
[[[RACSignal startEagerlyWithScheduler:[RACScheduler scheduler] block:^(id <RACSubscriber> subscriber) {
NSManagedObjectContext *context = [NSManagedObjectContext contextWithMainContext:self.managedObjectContext]; // self is AppDelegate
[context attachToCurrentScheduler];
[subscriber sendNext:nil];
[subscriber sendCompleted];
}] saveContext] subscribeCompleted:^{
NSLog(@"Completed");
}];
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment