Skip to content
This repository was archived by the owner on Sep 11, 2022. It is now read-only.

Commit a1aabb8

Browse files
committed
update example, moving from object mapper to Codable.
1 parent 35eb53e commit a1aabb8

File tree

14 files changed

+63
-205
lines changed

14 files changed

+63
-205
lines changed

Example/RxRetroSwift.xcodeproj/project.pbxproj

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
1515
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
1616
712BCB182504A8BFDBC5D776 /* Pods_RxRetroSwift_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B8B08090CD8A5D1162D6126 /* Pods_RxRetroSwift_Example.framework */; };
17-
A60A3CF81FFE9BD900A2B078 /* DefaultAPIClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60A3CF71FFE9BD900A2B078 /* DefaultAPIClient.swift */; };
17+
A60A3CF81FFE9BD900A2B078 /* APIClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60A3CF71FFE9BD900A2B078 /* APIClient.swift */; };
1818
A60A3D001FFEA21700A2B078 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60A3CFF1FFEA21700A2B078 /* User.swift */; };
1919
A60A3D021FFEA24900A2B078 /* ErrorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60A3D011FFEA24900A2B078 /* ErrorModel.swift */; };
20-
A60A3D091FFEA31700A2B078 /* APIClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60A3D081FFEA31700A2B078 /* APIClient.swift */; };
2120
A60A3D0B1FFEA72700A2B078 /* Company.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60A3D0A1FFEA72700A2B078 /* Company.swift */; };
2221
A60A3D0D1FFEA73600A2B078 /* Address.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60A3D0C1FFEA73600A2B078 /* Address.swift */; };
2322
A60A3D151FFFC36D00A2B078 /* RxRetroSwift_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A60A3D141FFFC36D00A2B078 /* RxRetroSwift_Tests.swift */; };
@@ -53,10 +52,9 @@
5352
84D12D93185D0D3667C58FB3 /* Pods-RxRetroSwift_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxRetroSwift_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RxRetroSwift_Tests/Pods-RxRetroSwift_Tests.debug.xcconfig"; sourceTree = "<group>"; };
5453
87209867DD4159F96FF94824 /* RxRetroSwift.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = RxRetroSwift.podspec; path = ../RxRetroSwift.podspec; sourceTree = "<group>"; };
5554
962D953FD0B34D690DD0201D /* Pods-RxRetroSwift_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxRetroSwift_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-RxRetroSwift_Example/Pods-RxRetroSwift_Example.release.xcconfig"; sourceTree = "<group>"; };
56-
A60A3CF71FFE9BD900A2B078 /* DefaultAPIClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultAPIClient.swift; sourceTree = "<group>"; };
55+
A60A3CF71FFE9BD900A2B078 /* APIClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIClient.swift; sourceTree = "<group>"; };
5756
A60A3CFF1FFEA21700A2B078 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
5857
A60A3D011FFEA24900A2B078 /* ErrorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorModel.swift; sourceTree = "<group>"; };
59-
A60A3D081FFEA31700A2B078 /* APIClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIClient.swift; sourceTree = "<group>"; };
6058
A60A3D0A1FFEA72700A2B078 /* Company.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Company.swift; sourceTree = "<group>"; };
6159
A60A3D0C1FFEA73600A2B078 /* Address.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Address.swift; sourceTree = "<group>"; };
6260
A60A3D121FFFC36D00A2B078 /* RxRetroSwift_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RxRetroSwift_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -170,7 +168,7 @@
170168
A60A3D041FFEA2A300A2B078 /* Services */ = {
171169
isa = PBXGroup;
172170
children = (
173-
A60A3CF71FFE9BD900A2B078 /* DefaultAPIClient.swift */,
171+
A60A3CF71FFE9BD900A2B078 /* APIClient.swift */,
174172
);
175173
path = Services;
176174
sourceTree = "<group>";
@@ -194,7 +192,6 @@
194192
A60A3D071FFEA30600A2B078 /* Protocols */ = {
195193
isa = PBXGroup;
196194
children = (
197-
A60A3D081FFEA31700A2B078 /* APIClient.swift */,
198195
);
199196
path = Protocols;
200197
sourceTree = "<group>";
@@ -446,12 +443,11 @@
446443
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
447444
A60A3D0B1FFEA72700A2B078 /* Company.swift in Sources */,
448445
A60A3D201FFFC44600A2B078 /* Comment.swift in Sources */,
449-
A60A3CF81FFE9BD900A2B078 /* DefaultAPIClient.swift in Sources */,
446+
A60A3CF81FFE9BD900A2B078 /* APIClient.swift in Sources */,
450447
A60A3D1E1FFFC43100A2B078 /* Post.swift in Sources */,
451448
A60A3D221FFFC46900A2B078 /* Album.swift in Sources */,
452449
A60A3D0D1FFEA73600A2B078 /* Address.swift in Sources */,
453450
A60A3D261FFFC48900A2B078 /* Todo.swift in Sources */,
454-
A60A3D091FFEA31700A2B078 /* APIClient.swift in Sources */,
455451
);
456452
runOnlyForDeploymentPostprocessing = 0;
457453
};

Example/RxRetroSwift/Models/Address.swift

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,10 @@ import Foundation
1010
import ObjectMapper
1111
import RxRetroSwift
1212

13-
struct Address {
13+
struct Address:Codable {
1414

1515
var street:String = ""
1616
var suite:String = ""
1717
var city:String = ""
1818
var zipcode:String?
1919
}
20-
21-
extension Address:Mappable {
22-
23-
init?(map: Map) {
24-
25-
}
26-
27-
mutating func mapping(map: Map) {
28-
29-
street <- map["street"]
30-
suite <- map["suite"]
31-
city <- map["city"]
32-
zipcode <- map["zipcode"]
33-
}
34-
}

Example/RxRetroSwift/Models/Album.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,9 @@ import Foundation
1010
import ObjectMapper
1111

1212

13-
struct Album {
13+
struct Album:Codable {
1414

1515
var userId:Int = 0
1616
var id:Int = 0
1717
var title:String = ""
1818
}
19-
20-
extension Album:Mappable {
21-
22-
init?(map: Map) {
23-
24-
}
25-
26-
mutating func mapping(map: Map) {
27-
userId <- map["userId"]
28-
id <- map["id"]
29-
title <- map["title"]
30-
}
31-
}

Example/RxRetroSwift/Models/Comment.swift

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,11 @@ import Foundation
1010
import ObjectMapper
1111

1212

13-
struct Comment {
13+
struct Comment:Codable {
1414

1515
var postId:Int = 0
1616
var id:Int = 0
1717
var email:String = ""
1818
var body:String = ""
1919
}
2020

21-
extension Comment:Mappable {
22-
23-
init?(map: Map) {
24-
25-
}
26-
27-
mutating func mapping(map: Map) {
28-
postId <- map["postId"]
29-
id <- map["id"]
30-
email <- map["email"]
31-
body <- map["postbodyId"]
32-
}
33-
}
34-

Example/RxRetroSwift/Models/Company.swift

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,9 @@ import Foundation
1010
import ObjectMapper
1111
import RxRetroSwift
1212

13-
struct Company {
13+
struct Company:Codable {
1414

1515
var name:String = ""
1616
var catchPhrase:String = ""
1717
var bs:String = ""
1818
}
19-
20-
extension Company:Mappable {
21-
22-
init?(map: Map) {
23-
24-
}
25-
26-
mutating func mapping(map: Map) {
27-
28-
name <- map["name"]
29-
catchPhrase <- map["catchPhrase"]
30-
bs <- map["bs"]
31-
}
32-
}

Example/RxRetroSwift/Models/ErrorModel.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,8 @@ import RxRetroSwift
1212
import RxCocoa
1313
import RxSwift
1414

15-
struct ErrorModel:HasErrorCode {
15+
struct ErrorModel:HasErrorCode, Codable {
1616

1717
var errorCode: Int = 0
18-
}
1918

20-
extension ErrorModel:Mappable {
21-
22-
init?(map: Map) {
23-
24-
}
25-
26-
mutating func mapping(map: Map) {
27-
28-
}
2919
}

Example/RxRetroSwift/Models/Photo.swift

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,11 @@ import Foundation
1010
import ObjectMapper
1111

1212

13-
struct Photo {
13+
struct Photo:Codable {
1414

1515
var albumId:Int = 0
1616
var id:Int = 0
1717
var title:String = ""
1818
var url:String = ""
1919
var thumbnailUrl:String = ""
2020
}
21-
22-
extension Photo:Mappable {
23-
24-
init?(map: Map) {
25-
26-
}
27-
28-
mutating func mapping(map: Map) {
29-
30-
albumId <- map["userId"]
31-
id <- map["id"]
32-
title <- map["title"]
33-
url <- map["url"]
34-
thumbnailUrl <- map["thumbnailUrl"]
35-
}
36-
}
37-

Example/RxRetroSwift/Models/Post.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,12 @@
99
import Foundation
1010
import ObjectMapper
1111

12-
struct Post {
12+
struct Post:Codable {
1313

1414
var userId:Int = 0
1515
var id:Int = 0
1616
var title:String = ""
1717
var body:String = ""
1818
}
1919

20-
extension Post:Mappable {
21-
22-
init?(map: Map) {
23-
24-
}
25-
26-
mutating func mapping(map: Map) {
27-
28-
userId <- map["id"]
29-
id <- map["id"]
30-
title <- map["title"]
31-
body <- map["body"]
32-
}
33-
34-
}
35-
3620

Example/RxRetroSwift/Models/Todo.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,10 @@ import Foundation
1010
import ObjectMapper
1111

1212

13-
struct Todo {
13+
struct Todo:Codable {
1414

1515
var userId:Int = 0
1616
var id:Int = 0
1717
var title:String = ""
1818
var completed:Bool = false
1919
}
20-
21-
22-
extension Todo:Mappable {
23-
24-
init?(map: Map) {
25-
26-
}
27-
28-
mutating func mapping(map: Map) {
29-
30-
userId <- map["userId"]
31-
id <- map["id"]
32-
title <- map["title"]
33-
completed <- map["completed"]
34-
}
35-
}

Example/RxRetroSwift/Models/User.swift

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import Foundation
99
import ObjectMapper
1010
import RxRetroSwift
1111

12-
struct User {
13-
var userId:Int = 0
12+
struct User:Codable {
13+
var id:Int = 0
1414
var name:String = ""
1515
var username:String = ""
1616
var email:String = ""
@@ -20,23 +20,3 @@ struct User {
2020
var address:Address?
2121
}
2222

23-
extension User:Mappable {
24-
25-
init?(map: Map) {
26-
if map.JSON["id"] == nil {
27-
return nil
28-
}
29-
}
30-
31-
mutating func mapping(map: Map) {
32-
33-
userId <- map["id"]
34-
name <- map["name"]
35-
username <- map["username"]
36-
email <- map["email"]
37-
phone <- map["phone"]
38-
website <- map["website"]
39-
company <- map["company"]
40-
address <- map["address"]
41-
}
42-
}

0 commit comments

Comments
 (0)