Changeset 282

Show
Ignore:
Timestamp:
01/17/08 07:56:25 (1 year ago)
Author:
wolf
Message:

[NEW] mogenerator: add +newInManagedObjectContext: and ObjC 2 property support.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cocoa/mogenerator/templates/machine.h.motemplate

    r281 r282  
    1010 
    1111@interface _<$managedObjectClassName$> : <$customSuperentity$> {} 
     12+ (id)newInManagedObjectContext:(NSManagedObjectContext*)moc_; 
     13 
    1214<$foreach Attribute noninheritedAttributes do$> 
    1315<$if Attribute.hasDefinedAttributeType$> 
    1416- (<$Attribute.attributeValueClassName$>*)<$Attribute.name$>; 
    1517- (void)set<$Attribute.name.initialCapitalString$>:(<$Attribute.attributeValueClassName$>*)value_; 
     18#if defined(MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 
     19@property (retain) <$Attribute.attributeValueClassName$> *<$Attribute.name$>; 
     20#endif 
    1621<$if Attribute.hasScalarAttributeType$> 
    1722- (<$Attribute.scalarAttributeType$>)<$Attribute.name$>Value; 
     
    2328<$foreach Relationship noninheritedRelationships do$> 
    2429<$if Relationship.isToMany$> 
     30- (NSSet*)<$Relationship.name$>; 
    2531- (void)add<$Relationship.name.initialCapitalString$>:(NSSet*)value_; 
    2632- (void)remove<$Relationship.name.initialCapitalString$>:(NSSet*)value_; 
     
    2834- (void)remove<$Relationship.name.initialCapitalString$>Object:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_; 
    2935- (NSMutableSet*)<$Relationship.name$>Set; 
     36#if defined(MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 
     37@property (retain) NSSet* <$Relationship.name$>; 
     38#endif 
    3039<$else$> 
    3140- (<$Relationship.destinationEntity.managedObjectClassName$>*)<$Relationship.name$>; 
    3241- (void)set<$Relationship.name.initialCapitalString$>:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_; 
    3342//- (BOOL)validate<$Relationship.name.initialCapitalString$>:(id*)value_ error:(NSError**)error_; 
     43#if defined(MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 
     44@property (retain) <$Relationship.destinationEntity.managedObjectClassName$>* <$Relationship.name$>; 
     45#endif 
    3446<$endif$> 
    3547<$endforeach do$> 
  • trunk/cocoa/mogenerator/templates/machine.m.motemplate

    r281 r282  
    55 
    66@implementation _<$managedObjectClassName$> 
     7 
     8+ (id)newInManagedObjectContext:(NSManagedObjectContext*)moc_ { 
     9        return [NSEntityDescription insertNewObjectForEntityForName:@"<$name$>" inManagedObjectContext:moc_];                                                                     
     10} 
     11 
    712<$foreach Attribute noninheritedAttributes do$> 
    813<$if Attribute.hasDefinedAttributeType$> 
     
    3843<$foreach Relationship noninheritedRelationships do$> 
    3944        <$if Relationship.isToMany$> 
     45 
     46- (NSSet*)<$Relationship.name$> { 
     47        [self willAccessValueForKey:@"<$Relationship.name$>"]; 
     48        NSSet *result = [self primitiveValueForKey:@"<$Relationship.name$>"]; 
     49        [self didAccessValueForKey:@"<$Relationship.name$>"]; 
     50        return result; 
     51} 
     52 
     53- (void)set<$Relationship.name.initialCapitalString$>:(NSSet*)value_ { 
     54        [self willChangeValueForKey:@"<$Relationship.name$>"]; 
     55        [self setPrimitiveValue:value_ forKey:@"<$Relationship.name$>"]; 
     56        [self didChangeValueForKey:@"<$Relationship.name$>"]; 
     57} 
     58 
    4059- (void)add<$Relationship.name.initialCapitalString$>:(NSSet*)value_ { 
    4160        [self willChangeValueForKey:@"<$Relationship.name$>" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value_];