提问人:Anthony 提问时间:4/28/2020 最后编辑:TylerPAnthony 更新时间:4/28/2020 访问量:270
Swift 闭包中“弱自我”的 Objective-C 等价物是什么?
What is the Objective-C equivalent of 'weak self' in a Swift closure?
问:
你能告诉我相当于:
var didTapURL: ((_ url: URL) -> Void)?
..........
myObject.didTapURL = { [weak self] (url) in
self?.manageUrl(url)
}
在 Objectice-C 中?
答:
1赞
Asperi
4/28/2020
#1
它是,见下文__weak
__weak __typeof(self) weakSelf = self;
// ...
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf call_some_selector];
});
评论