【发布时间】:2015-02-28 10:37:21
【问题描述】:
apiFunc(user: User.currentUser, start: 0, limit: Constants.numberOfItemInOnePage,
success: { [weak self] (friends) -> Void in
dispatch_async(dispatch_get_main_queue(), { [weak self] () -> Void in
if let strongSelf = self {
strongSelf.friendList = friends
strongSelf.loading = false
strongSelf.tableView.reloadData()
}
})
}, failure: nil)
错误
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
在编译上面的代码时发生,但是如果我删除第二个 [weak self],错误就会消失
apiFunc(user: User.currentUser, start: 0, limit: Constants.numberOfItemInOnePage,
success: { [weak self] (friends) -> Void in
dispatch_async(dispatch_get_main_queue(), { () -> Void in
if let strongSelf = self {
strongSelf.friendList = friends
strongSelf.loading = false
strongSelf.tableView.reloadData()
}
})
}, failure: nil)
我认为有 2 个闭包,应该是 2 个 [weak self],任何人都知道为什么会发生编译错误
【问题讨论】:
标签: swift closures grand-central-dispatch weak-references