Closed Dr1992 closed 5 years ago
Hello i have done in simple way.
class DiegoramosalmeidaModel{
class func getDiegoramosalmeida(){
let url = "https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls?state=all"
Alamofire.request(url, method: .get).responseJSON { (response) in
hideProgressHUD()
let status = response.response?.statusCode
print("STATUS \(status)")
switch response.result{
case .success(let value):
print(value)
if let val = value as? [[String : Any]]{
let model = Mapper<PullRequest>().mapArray(JSONArray: val)
print(model)
}else{
print("unable To Map")
}
case .failure(let error):
print(error)
}
}
}
}
class PullRequest: Mappable {
var id:Int?
var title: String?
var description: String?
var url:String?
var root : Int?
var htmlUrl : String?
var diffUrl : String?
var patchUrl : String?
var user : User?
required init?(map: Map) {
}
func mapping(map: Map) {
id <- map["id"]
title <- map["title"]
description <- map["description"]
htmlUrl <- map["html_url"]
diffUrl <- map["diff_url"]
patchUrl <- map["patch_url"]
user <- map["user"]
}
}
class User : Mappable{
var id:Int?
var login: String?
var avatarUrl: String?
var url:String?
required init?(map: Map) {
}
func mapping(map: Map) {
id <- map["id"]
login <- map["login"]
avatarUrl <- map["avatar_url"]
url <- map["url"]
}
}
If any problem fill free to ask me.
Hello dude, Please help me.
URL (GET) - "https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls?state=all"
This is what i get when i print the responseString
...
Mapper below
I always got