From 8902305650c68d7ba7550acb7f3c21ce42c02d93 Mon Sep 17 00:00:00 2001 From: rentzsch Date: Sat, 27 Mar 2010 14:36:39 -0500 Subject: [PATCH] [NEW] +[Machine entityName] (for @drance) and +[Machine entityInManagedObjectContext:] (from Michael Dales). --- mogeneratorTestMule/mogeneratorTestMule_AppDelegate.m | 1 + templates/machine.h.motemplate | 2 ++ templates/machine.m.motemplate | 9 +++++++++ 3 files changed, 12 insertions(+) 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]; }