【发布时间】:2015-05-18 09:58:50
【问题描述】:
我发现构造 __strong typeof(self)self = weakSelf。
它允许删除 NSAssert 宏 self 捕获,但我怀疑以这种方式使用它是否正确?
__weak typeof(self)weakSelf = self;
self.signupBlock = ^{
__strong typeof(self)self = weakSelf;
NSLog (@"%d", self.property)
NSAssert((self.property > 5), @"Some message");
}
请指教。
对不起,我不得不先说使用 __strong typeof(self)strongSelf = weakSelf;
构造结果是警告和我想mem循环,当使用NSAssert宏时,因为它包含self中。
【问题讨论】:
-
self有什么问题?weakSelf是干什么用的? -
因为 OP 在块中编写代码,限制直接访问其中的 self 对象。
-
不,一点也不。
标签: ios objective-c-blocks self