diff --git a/mogeneratorTestMule/mogeneratorTestMule_AppDelegate.m b/mogeneratorTestMule/mogeneratorTestMule_AppDelegate.m index 19cf475a..94d846c3 100644 --- a/mogeneratorTestMule/mogeneratorTestMule_AppDelegate.m +++ b/mogeneratorTestMule/mogeneratorTestMule_AppDelegate.m @@ -7,6 +7,7 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification_ { ParentMO *parent = [ParentMO insertInManagedObjectContext:[self managedObjectContext]]; [parent setIvar:42.0]; [parent setHairColor:[NSColor brownColor]]; + NSAssert([[ParentMO entityName] isEqualToString:@"Parent"], nil); NSLog(@"success"); [NSApp terminate:nil]; } diff --git a/templates/machine.h.motemplate b/templates/machine.h.motemplate index 9ad6ea61..c3b05b78 100644 --- a/templates/machine.h.motemplate +++ b/templates/machine.h.motemplate @@ -11,6 +11,8 @@ @interface _<$managedObjectClassName$> : <$customSuperentity$> {} + (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_; ++ (NSString*)entityName; ++ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_; - (<$managedObjectClassName$>ID*)objectID; <$foreach Attribute noninheritedAttributes do$> diff --git a/templates/machine.m.motemplate b/templates/machine.m.motemplate index 62189a61..5cdb4b35 100644 --- a/templates/machine.m.motemplate +++ b/templates/machine.m.motemplate @@ -13,6 +13,15 @@ return [NSEntityDescription insertNewObjectForEntityForName:@"<$name$>" inManagedObjectContext:moc_]; } ++ (NSString*)entityName { + return @"<$name$>"; +} + ++ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_ { + NSParameterAssert(moc_); + return [NSEntityDescription entityForName:@"<$name$>" inManagedObjectContext:moc_]; +} + - (<$managedObjectClassName$>ID*)objectID { return (<$managedObjectClassName$>ID*)[super objectID]; }