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个[weak self],但是为什么会出现编译错误,有人知道吗?