vendredi 29 juillet 2016

Swift 3 - URLRequest creation crashes

        let url = URL(string: "(SERVER_HOST)/post?fb_id=(fb_user)")
        var request = URLRequest(url: url!) // Crashes here

        Alamofire.request(request)
            .responseJSON { response in
                switch response.result {
                case .failure(let error):
                    onComplete(success: false)
                case .success(let responseObject):
                    onComplete(success: true)
                }
        }

The crash error:

fatal error: unexpectedly found nil while unwrapping an Optional value

It worked before the Swift 3.
It was NSURLRequest and it worked. What can I do in order to fix it?

Aucun commentaire:

Enregistrer un commentaire