I am Facing Problem while Using AlamofireObjectMaper in Alamofire for fetching Array of my Categorey Object
My Object :
import Foundation
import ObjectMapper
class Category: Mappable {
public var iDCategory: Int?
public var nameCategory: String?
public var img: String?
func mapping(map: Map) {
iDCategory <- map["IDCategory"]
nameCategory <- map["NameCategory"]
img <- map["img"]
}
required init?(map: Map) {
}
}
and my call :
import Foundation
import UIKit
import Alamofire
class ControllerSearch: UIViewController {
override func viewDidLoad() {
Alamofire.request("http://pazirandegan.farhadarghavan.ir/api/ApiCategory")
.responseArray { (response: DataResponse<[Category]>) in
for a in response.value!{
print(a.nameCategory!)
}
}
}
}
JsonArray:
[{"IDCategory":2,"NameCategory":"رستوران و کافه","img":"/Upload/Images/eb0c3cd1-d911-43bb-bf59-9b736a98c49e.PNG"},{"IDCategory":3,"NameCategory":"پوشاک و البسه","img":"/Upload/Images/5da2b69a-3063-4b34-a74b-64ba8fb166c6.jpg"},{"IDCategory":4,"NameCategory":"پزشکی و سلامت","img":"/Upload/Images/a8bb9506-7c31-4ed0-b05b-41d9a760ab43.jpg"},{"IDCategory":5,"NameCategory":"فروشگاه و زنجیره ای","img":null},{"IDCategory":6,"NameCategory":"لوازم خانگی","img":null},{"IDCategory":7,"NameCategory":"زیبایی","img":null},{"IDCategory":8,"NameCategory":"فرهنگ و هنر","img":"/Upload/Images/43958739-0f41-489f-882c-65c2e2fd6eb1.jpg"},{"IDCategory":9,"NameCategory":"خودرو","img":null},{"IDCategory":10,"NameCategory":"کالای دیجیتال","img":null}]
No Errors are there and Output is Perfect, But my App Crashes
Note : When Alamofire responseString
is Used Everything Works Fine.
Whats the Problem.