Objective-C在Swift闭包中 "弱自 "的等价物是什么?

问题描述 投票:0回答:1

你能告诉我在Objectice-C中:

var didTapURL: ((_ url: URL) -> Void)?

..........

myObject.didTapURL = { [weak self] (url) in
     self?.manageUrl(url)
}

在Objectice-C中的等价物是什么?

ios objective-c swift closures weak
1个回答
1
投票

它是 __weak见下文

__weak __typeof(self) weakSelf = self;

// ...

    dispatch_async(dispatch_get_main_queue(), ^{
      [weakSelf call_some_selector];
    });
© www.soinside.com 2019 - 2024. All rights reserved.