Created
October 18, 2012 19:01
-
-
Save basuke/3914115 to your computer and use it in GitHub Desktop.
To suppress the LLVM's "PerformSelector may cause a leak because its selector is unknown" warning...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| @interface NSObject(BasukeAddition) | |
| - (id)performSelectorIfExists:(SEL)aSelector; | |
| - (id)performSelectorIfExists:(SEL)aSelector withObject:(id)object; | |
| - (id)performSelectorIfExists:(SEL)aSelector withObject:(id)object1 withObject:(id)object2; | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "NSObject+BasukeAddition.h" | |
| @implementation NSObject(BasukeAddition) | |
| - (id)performSelectorIfExists:(SEL)aSelector | |
| { | |
| if ([self respondsToSelector:aSelector] == NO) return nil; | |
| #pragma clang diagnostic push | |
| #pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
| return [self performSelector:aSelector]; | |
| #pragma clang diagnostic pop | |
| } | |
| - (id)performSelectorIfExists:(SEL)aSelector withObject:(id)object | |
| { | |
| if ([self respondsToSelector:aSelector] == NO) return nil; | |
| #pragma clang diagnostic push | |
| #pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
| return [self performSelector:aSelector withObject:object]; | |
| #pragma clang diagnostic pop | |
| } | |
| - (id)performSelectorIfExists:(SEL)aSelector withObject:(id)object1 withObject:(id)object2 | |
| { | |
| if ([self respondsToSelector:aSelector] == NO) return nil; | |
| #pragma clang diagnostic push | |
| #pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
| return [self performSelector:aSelector withObject:object1 withObject:object2]; | |
| #pragma clang diagnostic pop | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment