Objective C eqivalent Swift代码?

时间:2015-07-16 09:40:03

标签: objective-c swift block class-method alamofire

这是一个类方法,我传递块作为参数之一那么基本上如何在swift中传递块?

+ (NSURLSessionDataTask *)getAllSongIfo:(NSDictionary *)userInfo withBlock:(void (^)(NSArray *songInfos, NSError *error))block;

1 个答案:

答案 0 :(得分:0)

Swift等价物:

func getAllSongIfo(userInfo: NSDictionary, withBlock block:((NSArray?, NSError?) -> Void)) -> NSURLSessionDataTask

如果您需要类方法,则需要添加class关键字,如:

class func getAllSongIfo(userInfo: NSDictionary, withBlock block:((NSArray?, NSError?) -> Void)) -> NSURLSessionDataTask