From 60af6e0b84fc07b014a62137d287ff9670b35477 Mon Sep 17 00:00:00 2001 From: Basit Mustafa Date: Mon, 20 Apr 2015 11:58:35 -0600 Subject: [PATCH] Fix for CBL-ios issue 648 https://github.com/couchbase/couchbase-lite-ios/issues/648 --- Source/API/CBLModel+Properties.m | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Source/API/CBLModel+Properties.m b/Source/API/CBLModel+Properties.m index 62e1290dd..5953d4ddc 100644 --- a/Source/API/CBLModel+Properties.m +++ b/Source/API/CBLModel+Properties.m @@ -238,7 +238,12 @@ + (IMP) impForGetterOfProperty: (NSString*)property ofClass: (Class)propertyClas return [receiver getArrayRelationProperty: property withModelClass: itemClass]; }; } - } else { + } + else if ( [itemClass isSubclassOfClass: [NSObject class]] && ![itemClass isSubclassOfClass:[NSDate class]]) + { + return [super impForGetterOfProperty: property ofClass: propertyClass]; + } + else { // Typed array of scalar class: ValueConverter itemConverter = valueConverterToClass(itemClass); if (itemConverter) { @@ -253,7 +258,12 @@ + (IMP) impForGetterOfProperty: (NSString*)property ofClass: (Class)propertyClas impBlock = ^id(CBLModel* receiver) { return [receiver getModelProperty: property]; }; - } else { + } + else if ( [propertyClass isSubclassOfClass: [NSObject class]] && ![propertyClass isSubclassOfClass:[NSDate class]]) + { + return [super impForGetterOfProperty: property ofClass: propertyClass]; + } + else { // Other property type -- use a ValueConverter if we have one: ValueConverter converter = valueConverterToClass(propertyClass); if (converter) { @@ -300,7 +310,13 @@ + (IMP) impForSetterOfProperty: (NSString*)property ofClass: (Class)propertyClas } [receiver setValue: value ofProperty: property]; }; - } else { + } + else if ([propertyClass isSubclassOfClass: [NSObject class]]) + { + return [super impForSetterOfProperty: property ofClass: propertyClass]; + } + + else { // Scalar-valued array: impBlock = ^(CBLModel* receiver, NSArray* value) { [receiver setValue: value ofProperty: property]; @@ -316,7 +332,12 @@ + (IMP) impForSetterOfProperty: (NSString*)property ofClass: (Class)propertyClas } [receiver setValue: value ofProperty: property]; }; - } else { + } + else if ([propertyClass isSubclassOfClass: [NSObject class]]) + { + return [super impForSetterOfProperty: property ofClass: propertyClass]; + } + else { return [super impForSetterOfProperty: property ofClass: propertyClass]; }