Clicky

iOS Dev Nugget 7 Suppress compiler warnings with #pragma

.

Need to run a code review on your codebase? Hire me

Ever gotten warnings such as "PerformSelector may cause a leak because its selector is unknown" when you send -performSelector:withObject: with the selector as a variable (that you know will contain a valid selector)? That's where #pragma is very useful. Do this to disable the warning for a specific chunk of code:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
    [self.proxiedTarget performSelector:someSelectorVar withObject:obj];
#pragma clang diagnostic pop


Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No

.

Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter

.

View archives of past issues