Forked from cyndibaby905/NSNUll+ InternalNullExtention.m
Last active
October 7, 2015 11:14
-
-
Save ytlvy/fc93eea346cda566bbbd to your computer and use it in GitHub Desktop.
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