Permalink
Browse files

Adds -attributeTypeName to attributes.

-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...
1 parent 64733a4 commit 01e5043ca41235b0809bf9fa818d4ee08112be5d @robrix robrix committed Jan 7, 2012
Showing with 7 additions and 0 deletions.
  1. +1 −0 mogenerator.h
  2. +6 −0 mogenerator.m
View
@@ -32,6 +32,7 @@
- (NSString*)scalarAttributeType;
- (BOOL)hasDefinedAttributeType;
- (NSString*)objectAttributeType;
+- (NSString*)attributeTypeName;
- (BOOL)hasTransformableAttributeType;
@end
View
@@ -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);

0 comments on commit 01e5043

Please sign in to comment.