I'm new to swift, and I'm having a difficult time figuring out why the code on https://www.parse.com/docs/ios_guide#users/iOS isn't working for me
var user = PFUser()
user.username = "myUsername"
user.password = "myPassword"
user.email = "email@example.com"
// other fields can be set just like with PFObject
user["phone"] = "415-392-0202"
user.signUpInBackgroundWithBlock {
(succeeded: Bool!, error: NSError!) -> Void in
if error == nil {
// Hooray! Let them use the app now.
} else {
let errorString = error.userInfo["error"] as NSString
// Show the errorString somewhere and let the user try again.
}
}
This line
user.signUpInBackgroundWithBlock
gives me the following error
Cannot invoke 'signUpInBackgroundWithBlock' with an argument list of type '((Bool!, NSError!) -> Void)'
I can copy and paste the code for Objective-C into my project and it works perfectly, but when I try to do the same with the Swift code. I get this error message. Is there something else I need to do to get it to work properly in Swift?
I found the solution in case others are having a similar problem. The code below seems to working just fine. Now I'm just curious to know why parse.com gives the above code in their documentation which doesn't actually work
user.signUpInBackgroundWithBlock {
(succeeded: Bool, error: NSError?) -> Void in
if error == nil {
// Hooray! Let them use the app now.
} else {
}
}