[Solved] Unexpectedly found nil while unwrapping an optional value while reading JSON [closed]
Instead of guard the data parameter handle the error returned in the completion handler. If there is no error then data can be safely unwrapped. let task = session.dataTaskWithURL(shotsUrl!, completionHandler: { (data,response,error) -> Void in if error != nil { // do proper error handling } else { do { let json = try NSJSONSerialization.JSONObjectWithData(data!, … Read more