我从公司文档中发现了这个代码片段:
可以保留吗?
__weak __typeof(self)weakSelf = self;
dispatch_async(dispatch_get_main_queue(),
^{
__strong __typeof(weakSelf)strongSelf = weakSelf;
// Do stuff
});
可以保留吗?
__strong typeof(self)strongSelf = weakSelf;
,因为在两种情况下都是相同的self
。 - Dennis W.__weak CLASSNAME *weakSelf = self;
并在代码块中使用 weakSelf 变量。 - Sunil Sharma