From eb4ff92f9f17372c49ca5b0c11a42f000a24c4f0 Mon Sep 17 00:00:00 2001 From: Jens Alfke Date: Mon, 4 May 2015 22:02:41 -0700 Subject: [PATCH] Fix for CBLModel getters of type 'id' (or Swift 'String') For some reason the prior fix was only implemented for setter methods, not getters, and the unit tests didn't notice because they only tested the untyped setter... Fixes #648 --- Source/API/CBLModel+Properties.m | 2 +- Unit-Tests/Model_Tests.m | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/API/CBLModel+Properties.m b/Source/API/CBLModel+Properties.m index 62e1290dd..480d40993 100644 --- a/Source/API/CBLModel+Properties.m +++ b/Source/API/CBLModel+Properties.m @@ -201,7 +201,7 @@ + (BOOL) hasRelation: (NSString*)relation { + (IMP) impForGetterOfProperty: (NSString*)property ofClass: (Class)propertyClass { id (^impBlock)(CBLModel*) = nil; - if (propertyClass == Nil) { + if (propertyClass == Nil || propertyClass == [NSObject class]) { // Untyped return [super impForGetterOfProperty: property ofClass: propertyClass]; } else if (propertyClass == [NSString class] diff --git a/Unit-Tests/Model_Tests.m b/Unit-Tests/Model_Tests.m index 09dbe0af4..a816f9de0 100644 --- a/Unit-Tests/Model_Tests.m +++ b/Unit-Tests/Model_Tests.m @@ -344,6 +344,7 @@ - (void) test00_SaveModel { AssertEqual(model.url, url); AssertEq(model.other, model3); AssertEqual(model.others, (@[model2, model3])); + AssertEqual(model.untypedObject, @"this is an id"); // Save it and make sure the save didn't trigger a reload: AssertEqual(db.unsavedModels, @[model]);