Skip to content

Commit

Permalink
Support for NSURL
Browse files Browse the repository at this point in the history
  • Loading branch information
Vermeer, Edwin authored and Vermeer, Edwin committed May 12, 2017
1 parent 1a552d0 commit ebfb863
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 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 = "4.11.0"
s.version = "4.12.0"
s.summary = "Reflection based (dictionary, JSON or XML) object mapping (including extensions for Alamofire and Moya with RxSwift or ReactiveSwift)"

s.description = <<-EOS
Expand Down
Binary file not shown.
8 changes: 4 additions & 4 deletions Source/EVReflection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -772,11 +772,9 @@ final public class EVReflection {
let convertedValue = dictionaryConverter.convertDictionary(key!, dict: theValue)
return (convertedValue, valueType, false)
}
}
if valueType == "Foundation.Date" {
} else if valueType == "Foundation.Date" {
return (theValue as! NSDate, "NSDate", false)
}
if valueType == "Foundation.Data" {
} else if valueType == "Foundation.Data" {
return (theValue as! NSData, "NSData", false)
}
let structAsDict = convertStructureToDictionary(theValue, conversionOptions: conversionOptions, isCachable: isCachable, parents: parents)
Expand Down Expand Up @@ -927,6 +925,8 @@ final public class EVReflection {
}
} else if typeInObject == "UUID" && (type == "String" || type == "NSString") {
value = UUID(uuidString: value as? String ?? "") as AnyObject? ?? UUID() as AnyObject
} else if typeInObject == "NSURL" && (type == "String" || type == "NSString") {
value = NSURL(string: value as? String ?? "")! as AnyObject
} else if (typeInObject == "NSDate" || typeInObject == "Date") && (type == "String" || type == "NSString") {
if let convertedValue = value as? String {
guard let date = getDateFormatter().date(from: convertedValue) else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class EVReflectionEventKitTests: XCTestCase {
func testEventKit() {

//TODO: fix
// Needs a workaround. See http://stackoverflow.com/questions/43686690/mirror-of-ekevent-does-not-show-the-data
return
let exp = expectation(description: "eventStore")

Expand Down
4 changes: 2 additions & 2 deletions UnitTests/EVReflectionTests/ProfilePhotoUrlListTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ProfilePhotoUrlListTests: XCTestCase {

func testJsonObject() {

let jsonDictOriginal = ["meta": ["limit": 1000, "offset": 0, "total_count": 4], "objects": [["id": 35, "index": 1, "resource_uri": "/api/v1/profilephotourl/35", "url": "a", "user": "/api/v1/user/1/"], ["id": 37, "index": 0, "resource_uri": "/api/v1/profilephotourl/37/", "url": "b", "user": "/api/v1/user/1/"], ["id": 36, "index": 3, "resource_uri": "/api/v1/profilephotourl/36/", "url": "c", "user": "/api/v1/user/1/"], ["id": 44, "index": 2, "resource_uri": "/api/v1/profilephotourl/44/", "url": "d", "user": "/api/v1/user/1"]]] as [String : Any]
let jsonDictOriginal = ["meta": ["limit": 1000, "offset": 0, "total_count": 4], "objects": [["id": 35, "index": 1, "resource_uri": "/api/v1/profilephotourl/35", "url": "http://evict.nl", "user": "/api/v1/user/1/"], ["id": 37, "index": 0, "resource_uri": "/api/v1/profilephotourl/37/", "url": "b", "user": "/api/v1/user/1/"], ["id": 36, "index": 3, "resource_uri": "/api/v1/profilephotourl/36/", "url": "c", "user": "/api/v1/user/1/"], ["id": 44, "index": 2, "resource_uri": "/api/v1/profilephotourl/44/", "url": "d", "user": "/api/v1/user/1"]]] as [String : Any]

print("Initial dictionary:\n\(jsonDictOriginal)\n\n")

Expand Down Expand Up @@ -69,7 +69,7 @@ class Meta: EVObject {
}

class ProfilePhotoUrl: Base {
var url: String?
var url: NSURL?
var index: Int = 0
var user: String?
var id: Int = 0
Expand Down

0 comments on commit ebfb863

Please sign in to comment.