I was working on my app and it works fine on simulator. While we I tried that on my iphone, it crashed with unwarpping error.Any ideas? Thx error screenshot
class connection{
var url: String = ""
func connectServer(url:String,completionHandler: (jsonResponse: JSON) -> ()) {
Alamofire.request(.GET, url)
.responseJSON { (response) in
let json = JSON(response.result.value!)
// print(json) // works fine
completionHandler(jsonResponse: json)
}
}
}
func loadData(){
let cn = connection()
let url = "http://localhost:3000/api/v1/patients/user_id/"+userID
// Call function to connect server by API with specific url
cn.connectServer(url) { (jsonResponse) in
//Parsing JSON file
for item in jsonResponse["patients"].arrayValue{
//pasring json
}
}}