Objective c 目标C到Swift方法调用?
这是我的objective c方法调用,我需要将其转换为swift调用 它抱怨“找不到接受所提供参数的logInWithUsernameInBackground的重载 我做错了什么 目的C法脱毒Objective c 目标C到Swift方法调用?,objective-c,swift,Objective C,Swift,这是我的objective c方法调用,我需要将其转换为swift调用 它抱怨“找不到接受所提供参数的logInWithUsernameInBackground的重载 我做错了什么 目的C法脱毒 typedef void (^PFUserResultBlock)(PFUser *user, NSError *error); + (void)logInWithUsernameInBackground:(NSString *)username
typedef void (^PFUserResultBlock)(PFUser *user, NSError *error);
+ (void)logInWithUsernameInBackground:(NSString *)username
password:(NSString *)password
block:(PFUserResultBlock)block;
目标C呼叫
[User logInWithUsernameInBackground:@""
password:@""
block:^(PFUser *user, NSError *error) {
NSLog(@"test");
}];
迅捷的
让编译器通过类型推断为您找出正确的类型
User.logInWithUsernameInBackground("",
password: "",
block: {
(user, error) in
NSLog("test")
}
)
请在Objective-C中显示此方法的声明。重要的不是您如何调用它。
{(用户,错误)在NSLog(“测试”)中)
将方法定义添加到我的question@BryanChen你能把它作为一个答案提交给我吗?Objective c用来为你自动完成块定义。在swift中闭包似乎不会发生这种情况
User.logInWithUsernameInBackground("",
password: "",
block: {
(user, error) in
NSLog("test")
}
)