性能选择器可能会导致泄漏,因为它的选择器是未知的。ARC编译器警告我如下:"performSelector may cause a leak because its selector is unknown".我要做的是:[_controller performSelector:NSSelectorFromString(@"someMethod")];为什么我会收到这样的警告?我知道编译器不能检查选择器是否存在,但是为什么会导致泄漏呢?我怎样才能更改我的代码,使我不再收到这个警告呢?
3 回答
LEATH
TA贡献1936条经验 获得超6个赞
#pragma clang diagnostic push#pragma clang diagnostic ignored "-Warc-performSelector-leaks" [self.ticketTarget performSelector: self.ticketAction withObject: self];#pragma clang diagnostic pop
#define SuppressPerformSelectorLeakWarning(Stuff) \ do { \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \ Stuff; \ _Pragma("clang diagnostic pop") \ } while (0)
SuppressPerformSelectorLeakWarning( [_target performSelector:_action withObject:self]);
id result;SuppressPerformSelectorLeakWarning( result = [_target performSelector:_action withObject:self]);
绝地无双
TA贡献1946条经验 获得超4个赞
- 3 回答
- 0 关注
- 373 浏览
添加回答
举报
0/150
提交
取消