如何在Objective-C文件中使用转义闭包调用Swift静态方法

时间:2018-06-21 13:12:25

标签: objective-c swift static-functions

我已将此静态函数快速编写,需要在Objective-C文件中调用

static func downloadVideo(url: String, onResult: @escaping(String?) -> ()){
    //some code
    onResult("done")
}

我很快就称呼它

Service.downloadVideo(url: "url") { (string) in
    print(string)
}

我应该如何在Objective-C文件中称呼它?

编辑: 我想应该看起来像这样吗?

[[Service new] downloadVideo:@"url" onResult:^{
    NSLog(@"success")
}];

1 个答案:

答案 0 :(得分:2)

您无需创建实例来调用静态方法。试试这个

[Service downloadVideo:@"url" onResult:^{
    NSLog(@"success")
}];