Skip to content

Commit

Permalink
better readable code
Browse files Browse the repository at this point in the history
  • Loading branch information
evermeer committed Apr 5, 2018
1 parent 8d9bd1f commit f27f302
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Binary file not shown.
2 changes: 2 additions & 0 deletions UnitTests/EVReflectionTests/EVReflectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ class EVReflectionTests: XCTestCase {
}

func testNestedArray(){
// For now using the propertyConverters workaround.
let json = "{\"array\":[[{\"openId\":\"value1\"},{\"openId\":\"value2\"}],[{\"openId\":\"value3\"},{\"openId\":\"value4\"}]]}"
let obj = A81b(json: json)
print(obj)
Expand All @@ -492,6 +493,7 @@ class EVReflectionTests: XCTestCase {
}

func testNestedNestedArray(){
// For now using the propertyConverters workaround.
let json = "{\"array\":[[[{\"openId\":\"value1\"},{\"openId\":\"value2\"},{\"openId\":\"value3\"}],[{\"openId\":\"value3\"},{\"openId\":\"value4\"}]]]}"
let obj = A81c(json: json)
print(obj)
Expand Down
14 changes: 12 additions & 2 deletions UnitTests/EVReflectionTests/TestObjects.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ class A81b: EVObject {
override func propertyConverters() -> [(key: String, decodeConverter: ((Any?) -> ()), encodeConverter: (() -> Any?))] {
return [(key: "array",
decodeConverter: {
self.array = (($0 as? NSArray)?.map { (($0 as? NSArray)?.map { A81(dictionary: ($0 as? NSDictionary ?? NSDictionary()))}) ?? [] }) ?? [[]]
self.array = (($0 as? NSArray)?.map {
(($0 as? NSArray)?.map {
A81(dictionary: ($0 as? NSDictionary ?? NSDictionary()))
}) ?? []
}) ?? [[]]
}, encodeConverter: { return self.array })]
}
}
Expand All @@ -284,7 +288,13 @@ class A81c: EVObject {
override func propertyConverters() -> [(key: String, decodeConverter: ((Any?) -> ()), encodeConverter: (() -> Any?))] {
return [(key: "array",
decodeConverter: {
self.array = (($0 as? NSArray)?.map { (($0 as? NSArray)?.map { (($0 as? NSArray)?.map { A81(dictionary: ($0 as? NSDictionary ?? NSDictionary()))}) ?? [] }) ?? [[]] }) ?? [[[]]]
self.array = (($0 as? NSArray)?.map {
(($0 as? NSArray)?.map {
(($0 as? NSArray)?.map {
A81(dictionary: ($0 as? NSDictionary ?? NSDictionary()))
}) ?? []
}) ?? [[]]
}) ?? [[[]]]
}, encodeConverter: { return self.array })]
}
}
Expand Down

0 comments on commit f27f302

Please sign in to comment.