【发布时间】:2014-07-23 00:41:24
【问题描述】:
这是我需要转换为快速调用的目标 c 方法调用。
它抱怨“找不到接受提供的参数的 logInWithUsernameInBackground 的重载。
我做错了什么?
Objective C 方法声明
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: PFUser?, error: NSError) -> Void in
NSLog("test")
}
)
【问题讨论】:
-
请在Objective-C中显示该方法的声明。重要的是,这不是你所说的那样。
-
{ (user, error) in NSLog("test")} -
在我的问题中添加了方法定义
-
@BryanChen 你能把它作为答案提交给我吗?
标签: objective-c swift