Skip to content

Commit

Permalink
Fix for protocol init limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
evermeer committed Nov 1, 2016
1 parent c3c1c8c commit e7bb982
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion AlamofireJsonToObjects.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Pod::Spec.new do |s|
#

s.name = "AlamofireJsonToObjects"
s.version = "2.2.0"
s.version = "2.3.0"
s.summary = "An Alamofire extension which converts JSON response data into swift objects using EVReflection"
s.description = "An Alamofire extension which converts JSON response data into swift objects using EVReflection. "
s.homepage = "https://github.com/evermeer/AlamofireJsonToObjects"
Expand All @@ -35,6 +35,7 @@ s.license = { :type => "MIT", :file => "LICENSE" }
#

s.author = "evermeer"
s.authors = { 'Edwin Vermeer' => 'edwin@evict.nl' }
s.social_media_url = "https://twitter.com/evermeer"

# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
9 changes: 7 additions & 2 deletions AlamofireJsonToObjects/AlamofireJsonToObjects.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ extension DataRequest {
}

if object == nil {
let parsedObject: T = T().getSpecificType(JSONToMap!) as? T ?? T(dictionary: JSONToMap!)
let instance: T = T()
let parsedObject: T = ((instance.getSpecificType(JSONToMap!) as? T) ?? instance)
let _ = EVReflection.setPropertiesfromDictionary(JSONToMap!, anyObject: parsedObject)
return .success(parsedObject)
} else {
Expand Down Expand Up @@ -122,7 +123,11 @@ extension DataRequest {

}

let parsedObject:[T] = (JSONToMap!).map { T(dictionary: ($0 as? NSDictionary ?? NSDictionary()))} as [T]
let parsedObject:[T] = (JSONToMap!).map {
let instance: T = T()
let _ = EVReflection.setPropertiesfromDictionary($0 as? NSDictionary ?? NSDictionary(), anyObject: instance)
return instance
} as [T]

return .success(parsedObject)
}
Expand Down
10 changes: 5 additions & 5 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- Alamofire (4.0.1)
- EVReflection (3.1.2)
- EVReflection (3.3.2)

DEPENDENCIES:
- Alamofire (from `https://github.com/Alamofire/Alamofire.git`)
Expand All @@ -14,16 +14,16 @@ EXTERNAL SOURCES:

CHECKOUT OPTIONS:
Alamofire:
:commit: b98fe26cb86c1c1227185d30b87bd57cb45fbe3c
:commit: c71f503898cb24d56857e4e6f0ec7899a9b6fc7b
:git: https://github.com/Alamofire/Alamofire.git
EVReflection:
:commit: 7588c46c8ebdd49f1f3c8fb868b6d6153caf6b31
:commit: a53304c7be4fb59faa6b5ff45e7345b410990022
:git: https://github.com/evermeer/EVReflection.git

SPEC CHECKSUMS:
Alamofire: 7682d43245de14874acd142ec137b144aa1dd335
EVReflection: 102d8ca777db55200f48b80d9628c8d50fb4109d
EVReflection: 9e7fa540f0f73131b496c2adcbfc6b15c5c99e51

PODFILE CHECKSUM: b23d0f295b1db58b718a1a6c6d39516f37f4e932

COCOAPODS: 1.1.0.rc.3
COCOAPODS: 1.1.1

0 comments on commit e7bb982

Please sign in to comment.