Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable instance method not found warning

I'm currently working on an NSProxy subclass which intercepts certain messages and never forwards them to anyone but just processes them, so these methods never really exist. And here comes the problem, obviously the compiler starts to complain about the missing method implementations and I can't figure out how to stop it, adding stub methods to the interface just to get the compiler to shut up doesn't work because the methods are arbitrary formed and I don't know them ahead (to make it a bit more specific, I'm asking for this project).

Ideally I would like to tell the compiler that it shouldn't do any method checking for this specific class at all, but as this seems rather unlikely I would also be happy for a #pragma or any other way (which doesn't include to shut the compiler up for every warning in the whole project/file!)

like image 970
JustSid Avatar asked Nov 13 '22 08:11

JustSid


1 Answers

Your switch statements aren't really arbitrary, they just could have an arbitrary length. For a broad number of lengths, you could go ahead and declare them for the benefit of the compiler (and you'd then get error checking, which you wouldn't if you just turned off the warning). For example:

typedef void (^ObjCCaseBlock)();

@interface NSObject ()
- (id)switch;
- (void)case:(NSString*)a :(ObjCCaseBlock)b;
- (void)case:(NSString*)a :(ObjCCaseBlock)b case:(NSString*)a :(ObjCCaseBlock)b;
- (void)case:(NSString*)a :(ObjCCaseBlock)b case:(NSString*)a :(ObjCCaseBlock)b case:(NSString*)a :(ObjCCaseBlock)b;
@end

Repeat for as many levels as is likely to occur (and you could add levels if it ever bumped into a problem). It's a little bit tedious, but not difficult.

like image 160
Rob Napier Avatar answered Dec 21 '22 01:12

Rob Napier