Skip to content

Commit

Permalink
Adds -attributeTypeName to attributes.
Browse files Browse the repository at this point in the history
-attributeTypeName uses the “attributeValueTypeName” field in userInfo if available, defaulting to the scalarAttributeType if any, or else the objectAttributeType suffixed with a *.

Intended for use in the templates, deprecating both -scalarAttributeType and -objectAttributeType.

Use case: transformable attributes with “id” as their type (as opposed to the unidiomatic and frankly weird NSObject *).
  • Loading branch information
robrix committed Jan 7, 2012
1 parent 64733a4 commit 01e5043
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions mogenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- (NSString*)scalarAttributeType;
- (BOOL)hasDefinedAttributeType;
- (NSString*)objectAttributeType;
- (NSString*)attributeTypeName;
- (BOOL)hasTransformableAttributeType;
@end

Expand Down
6 changes: 6 additions & 0 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ - (NSString*)objectAttributeType {
return [self attributeValueClassName];
}
}
- (NSString*)attributeTypeName {
return
[[self userInfo] objectForKey:@"attributeValueTypeName"]
?: [self scalarAttributeType]
?: [[self objectAttributeType] stringByAppendingString:@"*"];
}

- (BOOL)hasTransformableAttributeType {
return ([self attributeType] == NSTransformableAttributeType);
Expand Down

0 comments on commit 01e5043

Please sign in to comment.