Skip to content

Instantly share code, notes, and snippets.

@cyndibaby905
Created March 28, 2014 09:23
Show Gist options
  • Save cyndibaby905/9828745 to your computer and use it in GitHub Desktop.
Save cyndibaby905/9828745 to your computer and use it in GitHub Desktop.
NSNUll+ InternalNullExtention.m
#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