fatal error: unexpectedly found nil while unwrapping an Optional value
This is my code line:
let View = (VArray[0] as? [String : Any])?["views_count"] as! NSNumber
Can anyone help me apply try catch for this line? For Swift 3.1 of 4.
fatal error: unexpectedly found nil while unwrapping an Optional value
This is my code line:
let View = (VArray[0] as? [String : Any])?["views_count"] as! NSNumber
Can anyone help me apply try catch for this line? For Swift 3.1 of 4.
It's quite easy using optional
if let dictView = VArray[0] as? [String : Any], let viewsCount = dictView["views_count"] as? NSNumber {
print(viewsCount)
} else {
print("Cannot convert to NSNumber")
}