From 1930cd9e94bd070aa932e1ebc588e89711609975 Mon Sep 17 00:00:00 2001 From: Aleksandar Vacic Date: Thu, 13 Jul 2017 16:02:57 +0200 Subject: [PATCH] Adds two booleans you can use in the templates to figure out does the current attribute uses custom type (setup through userInfo) --- mogenerator.h | 2 ++ mogenerator.m | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/mogenerator.h b/mogenerator.h index 2e33094b..1d5761d8 100644 --- a/mogenerator.h +++ b/mogenerator.h @@ -32,12 +32,14 @@ @interface NSAttributeDescription (typing) - (BOOL)hasScalarAttributeType; - (BOOL)usesScalarAttributeType; +- (BOOL)usesCustomScalarAttributeType; - (NSString*)scalarAttributeType; - (NSString*)scalarAccessorMethodName; - (NSString*)scalarFactoryMethodName; - (BOOL)hasDefinedAttributeType; - (NSArray*)objectAttributeTransformableProtocols; - (BOOL)hasAttributeTransformableProtocols; +- (BOOL)usesCustomObjectAttributeType; - (NSString*)objectAttributeClassName; - (NSString*)objectAttributeType; - (BOOL)hasTransformableAttributeType; diff --git a/mogenerator.m b/mogenerator.m index 784f8c87..c27ede4f 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -443,6 +443,11 @@ - (BOOL)usesScalarAttributeType { } } +- (BOOL)usesCustomScalarAttributeType { + NSString *attributeValueScalarType = [[self userInfo] objectForKey:kAttributeValueScalarTypeKey]; + return (attributeValueScalarType != nil); +} + - (NSString*)scalarAttributeType { BOOL isUnsigned = [self isUnsigned]; @@ -584,6 +589,12 @@ - (NSArray*)objectAttributeTransformableProtocols { - (BOOL)hasAttributeTransformableProtocols { return [self hasTransformableAttributeType] && [[self userInfo] objectForKey:@"attributeTransformableProtocols"]; } + +- (BOOL)usesCustomObjectAttributeType { + NSString *attributeValueClassName = [[self userInfo] objectForKey:@"attributeValueClassName"]; + return (attributeValueClassName != nil); +} + - (NSString*)objectAttributeType { NSString *result = [self objectAttributeClassName]; if ([result isEqualToString:@"Class"]) {