performSelector may cause a leak because its selector is unknown

后端 未结 19 2599
小蘑菇
小蘑菇 2020-11-22 01:54

I\'m getting the following warning by the ARC compiler:

\"performSelector may cause a leak because its selector is unknown\".

Here\'s what

19条回答
  •  情书的邮戳
    2020-11-22 02:45

    For posterity's sake, I've decided to throw my hat into the ring :)

    Recently I've been seeing more and more restructuring away from the target/selector paradigm, in favor of things such as protocols, blocks, etc. However, there is one drop-in replacement for performSelector that I've used a few times now:

    [NSApp sendAction: NSSelectorFromString(@"someMethod") to: _controller from: nil];
    

    These seem to be a clean, ARC-safe, and nearly identical replacement for performSelector without having to much about with objc_msgSend().

    Though, I have no idea if there is an analog available on iOS.

提交回复
热议问题