Objective C 等效 Swift 代码?

Objective C eqivalent Swift code?

这是一个 class 方法,我将块作为参数之一传递 所以基本上如何在 swift 中传递块?

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

Swift相当于:

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

如果您想要 class 方法,您需要添加 class 关键字,例如:

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