0

Here is my objective c method call that I need to convert to a swift call.

It's complaining that "Could not find an overload for logInWithUsernameInBackground that accepts the supplied arguments.

What am I doing wrong?

Objective C Method Decleration

typedef void (^PFUserResultBlock)(PFUser *user, NSError *error); + (void)logInWithUsernameInBackground:(NSString *)username password:(NSString *)password block:(PFUserResultBlock)block; 

Objective C Call

[User logInWithUsernameInBackground:@"" password:@"" block:^(PFUser *user, NSError *error) { NSLog(@"test"); }]; 

Swift

User.logInWithUsernameInBackground("", password: "", block: { (user: PFUser?, error: NSError) -> Void in NSLog("test") } ) 
4
  • Please show the declaration of this method in Objective-C. That, not how you were calling it, is what's important. Commented Jul 23, 2014 at 0:48
  • { (user, error) in NSLog("test")} Commented Jul 23, 2014 at 0:48
  • Added method definition to my question Commented Jul 23, 2014 at 0:51
  • @BryanChen Can you submit that as an answer so that I can accept? Commented Jul 23, 2014 at 0:53

1 Answer 1

1

let compiler figure out the correct type for you with type inference

User.logInWithUsernameInBackground("", password: "", block: { (user, error) in NSLog("test") } ) 
Sign up to request clarification or add additional context in comments.

1 Comment

Objective c used to autocomplete the block definition for you. Doesn't seem like this is happening for closures in swift

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.