Swift 闭包中 'weak self' 的 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)
}
在 Objective-C 中?
是__weak
,见下文
__weak __typeof(self) weakSelf = self;
// ...
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf call_some_selector];
});
你能告诉我相当于:
var didTapURL: ((_ url: URL) -> Void)?
..........
myObject.didTapURL = { [weak self] (url) in
self?.manageUrl(url)
}
在 Objective-C 中?
是__weak
,见下文
__weak __typeof(self) weakSelf = self;
// ...
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf call_some_selector];
});