I\'m developing an iOS 5.0+ app with latest SDK.
I get a very strange error with this code:
- (NSMutableURLRequest*)setupRequestWithService:(NSString
In line with David H's answer, how about a category on NSNull that just uses ObjC's message forwarding to "do nothing", to emulate the runtime's behavior when sending messages to nil?
Like this:
@interface NSNull (ForwardInvocation)
@end
@implementation NSNull (ForwardInvocation)
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
return [NSNull methodSignatureForSelector:@selector(description)];
}
- (void)forwardInvocation:(NSInvocation *)anInvocation {
// do nothing; prevent 'unrecognized selector' crashes
}
@end
The [NSNull methodSignatureForSelector:@selector(description)]; takes advantage of the fact that NSNull inherits from NSObject, which provides the description method. This satisfies the forwarding mechanism requirement for implementing -methodSignatureForSelector:.