Created
March 28, 2014 09:23
-
-
Save cyndibaby905/9828745 to your computer and use it in GitHub Desktop.
NSNUll+ InternalNullExtention.m
This file contains 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
#define NSNullObjects @[@"",@0,@{},@[]] | |
@interface NSNull (InternalNullExtention) | |
@end | |
@implementation NSNull (InternalNullExtention) | |
- (NSMethodSignature*)methodSignatureForSelector:(SEL)selector | |
{ | |
NSMethodSignature* signature = [super methodSignatureForSelector:selector]; | |
if (!signature) { | |
for (NSObject *object in NSNullObjects) { | |
signature = [object methodSignatureForSelector:selector]; | |
if (signature) { | |
break; | |
} | |
} | |
} | |
return signature; | |
} | |
- (void)forwardInvocation:(NSInvocation *)anInvocation | |
{ | |
SEL aSelector = [anInvocation selector]; | |
for (NSObject *object in NSNullObjects) { | |
if ([object respondsToSelector:aSelector]) { | |
[anInvocation invokeWithTarget:object]; | |
return; | |
} | |
} | |
[self doesNotRecognizeSelector:aSelector]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment