请有人告诉我如何从swift中调用Objective c class中定义的“attemptLogin”登录函数
#import <Foundation/Foundation.h>
@interface LoginHandler : NSObject<NSURLConnectionDelegate,NSXMLParserDelegate>{
}
typedef void (^CustomCallback)(NSDictionary *responseObj);
-(void)attemptLogin:(NSString *)userName andPassword:(NSString *)password completionHandler:(CustomCallback) callback;
@end
,我在swift文件中调用
var loginHandler = LoginHandler();
loginHandler.attemptLogin(userMob, andPassword: userPass){
data in
}
但是data
以NSObject形式返回,但它应该是NSDictionary
答案 0 :(得分:0)
假设您在Objective C中有阻止 -
[[MyDataStore instance] askUserForMe:^(Person *person, NSError *error){
// do things with myself that aren't strange
}];
以下代码将是您从swift调用的时间 -
MyDataStore.instance().askUserForMe() {
person, error in
// do things with myself that aren't strange
}