diff --git a/EVReflection.podspec b/EVReflection.podspec index c37e14f4..9b167e39 100755 --- a/EVReflection.podspec +++ b/EVReflection.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "EVReflection" - s.version = "5.1.3" + s.version = "5.1.4" s.summary = "Reflection based (Dictionary, CKRecord, NSManagedObject, Realm, JSON and XML) object mapping with extensions for Alamofire and Moya with RxSwift or ReactiveSwift" s.description = <<-EOS diff --git a/EVReflection.xcworkspace/xcuserdata/eve21962.xcuserdatad/UserInterfaceState.xcuserstate b/EVReflection.xcworkspace/xcuserdata/eve21962.xcuserdatad/UserInterfaceState.xcuserstate index 2aa54a11..9e71935c 100644 Binary files a/EVReflection.xcworkspace/xcuserdata/eve21962.xcuserdatad/UserInterfaceState.xcuserstate and b/EVReflection.xcworkspace/xcuserdata/eve21962.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Source/EVReflection.swift b/Source/EVReflection.swift index 79da0e1e..4c14636c 100755 --- a/Source/EVReflection.swift +++ b/Source/EVReflection.swift @@ -1251,6 +1251,9 @@ final public class EVReflection { valid = isValid } else if !type.hasPrefix("Swift.Array<") && !type.hasPrefix("Swift.Set<") { if let array = dictValue as? NSArray { + if anyObject is EVCustomReflectable { + return (array, true) + } if let org = anyObject as? EVReflectable { org.addStatusMessage(.InvalidType, message: "Did not expect an array for \(key). Will use the first item instead.") evPrint(.InvalidType, "WARNING: Did not expect an array for \(key). Will use the first item instead.") diff --git a/Source/Realm/RealmListEVCustomReflectable.swift b/Source/Realm/RealmListEVCustomReflectable.swift index 76a0d005..7c35e04e 100644 --- a/Source/Realm/RealmListEVCustomReflectable.swift +++ b/Source/Realm/RealmListEVCustomReflectable.swift @@ -87,7 +87,12 @@ extension List : EVCustomReflectable { self.append(element) } } - + } else if let array = value as? NSArray { + for item in array { + if let element: Element = item as? Element { + self.append(element) + } + } } } diff --git a/UnitTests/RealmTestIssue221.swift b/UnitTests/RealmTestIssue221.swift index 82b1fc17..0d08de59 100644 --- a/UnitTests/RealmTestIssue221.swift +++ b/UnitTests/RealmTestIssue221.swift @@ -17,7 +17,7 @@ import EVReflection class CategoryModel: Object, EVReflectable { - @objc dynamic var children = "" + let children = List() @objc dynamic var id = "" @objc dynamic var isRoot = false let name = List() diff --git a/UnitTests/RealmTests/RealmTests.swift b/UnitTests/RealmTests/RealmTests.swift index 194675ba..759f52fe 100755 --- a/UnitTests/RealmTests/RealmTests.swift +++ b/UnitTests/RealmTests/RealmTests.swift @@ -40,6 +40,10 @@ class Car: Object, EVReflectable { } } +class PrimitiveListsObject: Object, EVReflectable { + let strings = List() + let optionalInt = RealmOptional() +} /** @@ -135,9 +139,13 @@ class RealmTests: XCTestCase { print("Number of persons in database after delete = \(realm.objects(Person.self).count)") //: Thanks! To learn more about Realm go to https://realm.io } + + func testPrimitiveLists() { + let obj = PrimitiveListsObject(json: "{\"strings\":[\"a\",\"b\",\"c\"]}") + print("The object: \(obj)") + } } -