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