Forked from cyndibaby905/NSNUll+ InternalNullExtention.m
Created
July 4, 2014 09:44
-
-
Save gluttony/588f73f666df921fc56e 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