performSelector may cause a leak because its selector is unknown

This is very popular question in StackOverflow.

However, the best answer for XCode 4.6 is this:
“In your project Build Settings, under Other Warning Flags (WARNING_CFLAGS), add
-Wno-arc-performSelector-leaks

Now just make sure that the selector you are calling does not cause your object to be retained or copied.”

“Note you can add the same flag for specific files rather than the entire project. If you look under Build Phases->Compile Sources, you can set per file Compiler Flags (just like you want to do for excluding files from ARC). In my project just one file should use selectors this way, so I just excluded it and left the others.”

Code snippet:

Leave a Reply

Your email address will not be published. Required fields are marked *