Skip to content

Commit

Permalink
[NEW] +[Machine entityName] (for @drance) and +[Machine entityInManag…
Browse files Browse the repository at this point in the history
…edObjectContext:] (from Michael Dales).
  • Loading branch information
rentzsch committed Mar 27, 2010
1 parent d6df0ee commit 8902305
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions mogeneratorTestMule/mogeneratorTestMule_AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
2 changes: 2 additions & 0 deletions templates/machine.h.motemplate
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

@interface _<$managedObjectClassName$> : <$customSuperentity$> {}
+ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_;
+ (NSString*)entityName;
+ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_;
- (<$managedObjectClassName$>ID*)objectID;

<$foreach Attribute noninheritedAttributes do$>
Expand Down
9 changes: 9 additions & 0 deletions templates/machine.m.motemplate
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit 8902305

Please sign in to comment.