Skip to content

Instantly share code, notes, and snippets.

@fgarcia
Created November 23, 2012 10:07
Show Gist options
  • Save fgarcia/4134870 to your computer and use it in GitHub Desktop.
Save fgarcia/4134870 to your computer and use it in GitHub Desktop.
#post Surviving Core Data 3
- (void)awakeFromInsert
{
[super awakeFromInsert];
BOOL in_main_context = self.managedObjectContext == MAIN_CONTEXT;
if (! in_main_context) return;
if (self.initialized) return;
self.todayStats = [Stats MR_createInContext:[self managedObjectContext]];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSManagedObjectID *self_id = [self objectID];
[nc postNotificationName:FGN_NEW_CONTENT_NOTIFICATION object:self_id];
self.initialized = YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment