小编Yur*_*rov的帖子

闭包不能隐式捕获自身参数.迅速

我有一个错误"Closure不能隐式捕获自我参数".请告诉我它是如何解决的?

struct RepoJson {
...
    static func get(url: String, completion: @escaping (RepoJson!) -> ()) {
        ...
    }
} 

struct UsersJson {
    var repo: RepoJson!
    init() throws {   
        RepoJson.get(url: rep["url"] as! String) { (results:RepoJson?) in
            self.repo = results //error here
        }
   }
}
Run Code Online (Sandbox Code Playgroud)

xcode closures swift

1
推荐指数
1
解决办法
5832
查看次数

标签 统计

closures ×1

swift ×1

xcode ×1