Compiler Warning Not Found

I create a class from a string, verify that it is valid, and then check to see if it matches a particular method. If so, I call the method. Everything works fine, except that I get an annoying compiler warning: "warning: no" -setCurrentID: "method found". Am I something wrong here? Do I need to tell the compiler everything is okay and prevent it from reporting a warning?

Here is the code:

// Create an instance of the class
id viewController = [[NSClassFromString(class) alloc] init];

// Check the class supports the methods to set the row and section
if ([viewController respondsToSelector:@selector(setCurrentID:)]) 
    {
        [viewController setCurrentID:itemID];
    }   

// Push the view controller onto the tab bar stack      
[self.navigationController pushViewController:viewController animated:YES];
[viewController release];

Greetings

Dave

+3
source share
1 answer

, , , . .

@interface NSObject (MyInformalProtocol)

- (void)setCurrentID:(int)id;

@end
+7

Source: https://habr.com/ru/post/1746839/


All Articles