Skip to content

Commit

Permalink
fix the toDictionary for realm list with primitive types
Browse files Browse the repository at this point in the history
  • Loading branch information
evermeer committed Mar 29, 2018
1 parent 4ef2678 commit c15c0e9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion EVReflection.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "EVReflection"
s.version = "5.5.5"
s.version = "5.5.6"
s.summary = "Reflection based object mapping. (Dictionary, CKRecord, NSManagedObject, Realm, JSON, XML, Alamofire, Moya, RxSwift, ReactiveSwift)"

s.description = <<-EOS
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions Source/Realm/RealmListEVCustomReflectable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ extension List : EVCustomReflectable {
- returns: Dictionary without custom properties key
*/
public func toCodableValue() -> Any {
var q = [NSDictionary]()
var q:[Any] = []
for case let e as Any in self {
q.append((e as? EVReflectable)?.toDictionary([.PropertyConverter, .KeyCleanup, .PropertyMapping, .DefaultSerialize]) ?? NSDictionary())
q.append((e as? EVReflectable)?.toDictionary([.PropertyConverter, .KeyCleanup, .PropertyMapping, .DefaultSerialize]) ?? e)
}
return q

Expand Down
8 changes: 7 additions & 1 deletion UnitTests/RealmTests/RealmTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class RealmTests: XCTestCase {
// Now the object printed using Realm output functionality which just repeats itself until maximum depth is exeeded
print("wife = \(wife)")


//: IV. Write objects to the realm

try! realm.write {
Expand Down Expand Up @@ -147,6 +146,13 @@ class RealmTests: XCTestCase {
//TODO: Fix Crash introduced after adding super.setValue(value, forUndefinedKey: key) in the Object extension
//XCTAssertEqual(obj.optionalInt.value, 3, "The optional int should have been set to 3")
print("The object: \(obj)")

// Test to and from dictionary
let dict = obj.toDictionary()
print("dict = \(dict)")
let newObj = PrimitiveListsObject(dictionary: dict)
print("newObj = \(newObj)")

}

func testIssue270() {
Expand Down

0 comments on commit c15c0e9

Please sign in to comment.