Swift AFNetworking POST 错误
Swift AFNetworking POST error
我收到以下错误。我的 XCode 7.1 版,
/Users/chamath/Desktop/SwiftNvoi/Mobile/Mobile/APISFAuthentication.swift:30:22: 无法将类型 '(AFHTTPRequestOperation!, NSError!) -> ()' 的值转换为预期的参数类型 '((AFHTTPRequestOperation?, NSError ) -> 无效)?'
import Foundation
class APISFAuthentication {
init(x: Float, y: Float) {
}
func fAuthenticateUser(userEmail: String) -> String {
let manager = AFHTTPRequestOperationManager()
let postData = ["grant_type":"password","client_id":APISessionInfo.SF_CLIENT_ID,"client_secret":APISessionInfo.SF_CLIENT_SECRET,"username":APISessionInfo.SF_GUEST_USER,"password":APISessionInfo.SF_GUEST_USER_PASSWORD]
manager.POST(APISessionInfo.SF_APP_URL,
parameters: postData,
success: { (operation: AFHTTPRequestOperation!,responseObject: AnyObject!) in
print("JSON: " + responseObject.description)
},
failure: { (operation: AFHTTPRequestOperation!,error: NSError!) in
print("Error: " + error.localizedDescription)
})
}
}
在块中填写参数时不需要指定class类型。像这样更新参数:
func fAuthenticateUser(userEmail: String) -> String {
let manager = AFHTTPRequestOperationManager()
let postData = ["grant_type":"password","client_id":APISessionInfo.SF_CLIENT_ID,"client_secret":APISessionInfo.SF_CLIENT_SECRET,"username":APISessionInfo.SF_GUEST_USER,"password":APISessionInfo.SF_GUEST_USER_PASSWORD]
manager.POST(APISessionInfo.SF_APP_URL,
parameters: postData,
success: { (operation, responseObject) in
print("JSON: " + responseObject.description)
},
failure: { (operation, error) in
print("Error: " + error.localizedDescription)
})
}
我收到以下错误。我的 XCode 7.1 版,
/Users/chamath/Desktop/SwiftNvoi/Mobile/Mobile/APISFAuthentication.swift:30:22: 无法将类型 '(AFHTTPRequestOperation!, NSError!) -> ()' 的值转换为预期的参数类型 '((AFHTTPRequestOperation?, NSError ) -> 无效)?'
import Foundation
class APISFAuthentication {
init(x: Float, y: Float) {
}
func fAuthenticateUser(userEmail: String) -> String {
let manager = AFHTTPRequestOperationManager()
let postData = ["grant_type":"password","client_id":APISessionInfo.SF_CLIENT_ID,"client_secret":APISessionInfo.SF_CLIENT_SECRET,"username":APISessionInfo.SF_GUEST_USER,"password":APISessionInfo.SF_GUEST_USER_PASSWORD]
manager.POST(APISessionInfo.SF_APP_URL,
parameters: postData,
success: { (operation: AFHTTPRequestOperation!,responseObject: AnyObject!) in
print("JSON: " + responseObject.description)
},
failure: { (operation: AFHTTPRequestOperation!,error: NSError!) in
print("Error: " + error.localizedDescription)
})
}
}
在块中填写参数时不需要指定class类型。像这样更新参数:
func fAuthenticateUser(userEmail: String) -> String {
let manager = AFHTTPRequestOperationManager()
let postData = ["grant_type":"password","client_id":APISessionInfo.SF_CLIENT_ID,"client_secret":APISessionInfo.SF_CLIENT_SECRET,"username":APISessionInfo.SF_GUEST_USER,"password":APISessionInfo.SF_GUEST_USER_PASSWORD]
manager.POST(APISessionInfo.SF_APP_URL,
parameters: postData,
success: { (operation, responseObject) in
print("JSON: " + responseObject.description)
},
failure: { (operation, error) in
print("Error: " + error.localizedDescription)
})
}