diff --git a/mogenerator.h b/mogenerator.h index d28819d6..8f7a293b 100644 --- a/mogenerator.h +++ b/mogenerator.h @@ -37,6 +37,7 @@ - (NSString*)objectAttributeClassName; - (NSString*)objectAttributeType; - (BOOL)hasTransformableAttributeType; +- (BOOL)isReadonly; @end @interface NSRelationshipDescription (collectionClassName) diff --git a/mogenerator.m b/mogenerator.m index 76c462ff..8c651826 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -356,6 +356,15 @@ - (NSString*)objectAttributeType { - (BOOL)hasTransformableAttributeType { return ([self attributeType] == NSTransformableAttributeType); } + +- (BOOL)isReadonly { + NSString *readonlyUserinfoValue = [[self userInfo] objectForKey:@"mogenerator.readonly"]; + if (readonlyUserinfoValue != nil) { + return YES; + } + return NO; +} + @end @implementation NSRelationshipDescription (collectionClassName) diff --git a/templates/machine.h.motemplate b/templates/machine.h.motemplate index c544b399..54ebb028 100644 --- a/templates/machine.h.motemplate +++ b/templates/machine.h.motemplate @@ -32,10 +32,18 @@ extern const struct <$managedObjectClassName$>FetchedProperties {<$foreach Fetch <$foreach Attribute noninheritedAttributes do$> <$if Attribute.hasDefinedAttributeType$> <$if TemplateVar.arc$> +<$if Attribute.isReadonly$> +@property (nonatomic, strong, readonly) <$Attribute.objectAttributeType$> <$Attribute.name$>; +<$else$> @property (nonatomic, strong) <$Attribute.objectAttributeType$> <$Attribute.name$>; +<$endif$> +<$else$> +<$if Attribute.isReadonly$> +@property (nonatomic, retain, readonly) <$Attribute.objectAttributeType$> <$Attribute.name$>; <$else$> @property (nonatomic, retain) <$Attribute.objectAttributeType$> <$Attribute.name$>; <$endif$> +<$endif$> <$if Attribute.hasScalarAttributeType$> @property <$Attribute.scalarAttributeType$> <$Attribute.name$>Value; - (<$Attribute.scalarAttributeType$>)<$Attribute.name$>Value;