Alamofire - 在解开可选值时意外地发现了nil

时间:2015-12-11 08:00:07

标签: swift parameters swift2 alamofire

每当我尝试调用该函数时,它会在解开可选值时抛出意外发现的错误nil。我甚至尝试在setCustomerLocality函数中传递静态值。但似乎没有什么对我有用。我认为我传递参数的方式给了我这个问题。 enter image description here

 func setCustomerLocality(){
                          let url = NSURL(string: "http://test.idelivr.com/v2/client/set_customer_locality/fbId/6")

        let parameter : [String: AnyObject]? = [

                "street":"street",

                "city":"Kathmandu",

                "state":"state",

                "country":"Nepal",

                "latitude":"27.710878",

                "longitude":"85.31728299999997"
            ]

        let header  = ["accessToken" : DEFAULTS.valueForKey("accessToken") as! String ,"Content-Type" : "Application/JSON"] as [String:String]?
         Alamofire
        .request(.POST, url!, parameters: parameter  , encoding : .JSON , headers: header)
                .responseJSON{ response in
                    print("^^^^^")
                    print("|||||||||||||")
                    print("The json result in customer locality is \(response.result.value)")
                    print("The overal response is \(response.response)")
                    if response.result.error == nil {
                        if response.response != nil {
                            if response.response!.statusCode >= 200 && response.response?.statusCode < 300 {
                                self.delegate.setCustomerLocalityResponse!(response.result.value as! NSDictionary)

                            }

0 个答案:

没有答案