【问题标题】:Objective C eqivalent Swift code?Objective C等效的Swift代码?
【发布时间】:2015-10-05 16:30:21
【问题描述】:

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

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

【问题讨论】:

  • 如果有某种全球搜索引擎可以让您提问...

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


【解决方案1】:

Swift 等价物:

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

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

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

【讨论】:

    猜你喜欢
    • 2014-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-02
    • 2014-08-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多