我有一個錯誤「Closure不能隱式捕獲自我參數」。請告訴我它是如何修復的?關閉不能隱式捕獲自我參數。 Swift
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
}
}
}
可能重複的[閉包不能隱式捕獲變異自參數](https://stackoverflow.com/questions/41940994/closure-cannot-implicitly-capture-a-mutating-self-paramter) – Moriya