Xcode 7 Cast from Xcuielement to Unrelated Type 'string' Always Fails While Fetching JSON

Cast from 'JSON' to unrelated type 'String' always fails

You should use SwiftyJSON's built in String converter to convert the value to an optional String.

vc.passenger_id = json["user_id"].string

For Loop Swift: Cast from to unrelated type always fails

I think I got it right. I declared it as a string object first. Is
this a good approach?

let videos = json["result"] as! [String:AnyObject]

for dict in videos["videos"] as! [[String: AnyObject]] {
let VideoCategory = videoCategory()
VideoCategory.setValuesForKeys(dict)
videoCategories.append(VideoCategory)
}

Cast from UITableViewCell to unrelated type UIView always fails iOS9

You shouldn't cast it.

This should be enough

let result = tableView.dequeueReusableCellWithIdentifier("CustomHeader")

where result is UITableViewCell?

If you have a custom UITableViewCell, let's call it customTableViewCell, you can do the following:

let result = tableView.dequeueReusableCellWithIdentifier("CustomHeader") as! customTableViewCell


Related Topics



Leave a reply



Submit