Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow an attribute property to be specified readonly #111

Merged
merged 1 commit into from
May 18, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mogenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- (NSString*)objectAttributeClassName;
- (NSString*)objectAttributeType;
- (BOOL)hasTransformableAttributeType;
- (BOOL)isReadonly;
@end

@interface NSRelationshipDescription (collectionClassName)
Expand Down
9 changes: 9 additions & 0 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions templates/machine.h.motemplate
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down