Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppressing Class Method Not Found Warnings in Xcode [duplicate]

I have a class whose methods are determined at runtime, as indicated in my question here. This works great, but now I have a bunch of warnings that look like the following littering my code:

Class method '+objectIsNotNil:' not found (return type defaults to 'id')

While these warnings don't actually affect the build process, they're very annoying and make it harder to spot relevant warnings. Is there some way to disable them, but only for the Assert class (maybe some kind of macro)? If this isn't possible, then is there some way to turn them off for the entire build?

like image 631
LandonSchropp Avatar asked Aug 31 '11 22:08

LandonSchropp


2 Answers

One alternative would be to use performSelector:withObject: instead of the direct method call. So instead of:

[Assert objectIsNotNil:object];

You could have:

[Assert performSelector:@selector(objectIsNotNil:) withObject:object];

It does not look quite as nice but it will remove the warnings. Furthermore, this pattern will work for any selector you want. To make things look a little better you could use macros in the following way:

#define ASSERT_PRECONDITION(sel, obj)  [Assert performSelector:@selector(sel) withObject:obj]

This way your assert would look like this:

ASSERT_PRECONDITION(objectIsNotNil:, object);
like image 85
aLevelOfIndirection Avatar answered Sep 22 '22 21:09

aLevelOfIndirection


these cases should be extremely rare...

I've declared a hidden protocol which declared the methods with proper signatures. 'Hidden' in the sense that it was only included by the translations which needed them.

@protocol MONRuntimeClassInterface
+ (BOOL)objectIsNotNil:(id)object;
@end
like image 37
justin Avatar answered Sep 24 '22 21:09

justin