Why is there a warning? Can I ignore it?
I'm getting the following warning by the ARC compiler
performSelector may cause a leak because its selector is unknown
This is my code:
[self performSelector:config.selector];
Why do I get this warning? I understand the compiler can't check if the selector exists or not, but why would that cause a leak? And how can I change my code so that I don't get this warning anymore?
As @rmaddy points out, this is a duplicate of performSelector may cause a leak because its selector is unknown
There is a better solution than either suppressing the warning or playing other games.
Instead of using the SEL
, use callback blocks instead.
Ie instead of config.selector
, go for config.handlerBlock(...)
.
That way, you have full type safety throughout, nothing gets in the way of using ARC, and no #pragma dance to disable warnings temporarily or anything.
链接地址: http://www.djcxy.com/p/19952.html上一篇: 用Java在常量时间内合并两个列表
下一篇: 为什么会有警告? 我可以忽略它吗?