请告诉我如何从swift调用objective c类中定义的“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

最佳答案

假设你在目标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
}

09-07 12:02