Created
May 20, 2012 09:32
-
-
Save kishikawakatsumi/2757488 to your computer and use it in GitHub Desktop.
merge managed context in CoreData
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// バックグラウンドでGoogle Calendarからイベントを受信して保存するクラス | |
- (void)main { | |
if (!self.isCancelled) { | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
if (!self.isCancelled) { | |
NSManagedObjectContext *managedObjectContext = [self managedObjectContext]; | |
[managedObjectContext setMergePolicy:NSMergeByPropertyObjectTrumpMergePolicy]; | |
SPEventStore *eventStore = [SPEventStore defaultEventStore]; | |
events = [[eventStore searchEventsWithPredicate:predicate] retain]; | |
} | |
[pool release]; | |
if (!self.isCancelled) { | |
[resultsDelegate performSelectorOnMainThread:@selector(operationSearchEnded:) withObject:self waitUntilDone:NO]; | |
} | |
} | |
} | |
// メインスレッドのコンテキストを管理しているクラス | |
- (void)anotherContextDidSave:(NSNotification *)notification { | |
[managedObjectContext mergeChangesFromContextDidSaveNotification:notification]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment