Reputation: 5172
I am getting the following error. My XCode version 7.1 ,
/Users/chamath/Desktop/SwiftNvoi/Mobile/Mobile/APISFAuthentication.swift:30:22: Cannot convert value of type '(AFHTTPRequestOperation!, NSError!) -> ()' to expected argument type '((AFHTTPRequestOperation?, NSError) -> Void)?'
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)
})
}
}
Upvotes: 0
Views: 1333
Reputation: 3077
You don't need to specify the class type when filling in the parameters in a block. Update the parameters like this:
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)
})
}
Upvotes: 2