repondsToSelector: Undeclared selector warning, working fine at run time

733 views Asked by At

I have a larger project, where this code does not create warnings. I created a small new project just to try different ideas for the destination View Controller.

I have searched through all the previous answers to similar questions and have the following thoughts.

1) I could ignore the warnings as it works just fine, but I don't want to.

2) Why do I not get warnings on the larger project but I do on this new one? Have I forgotten something when I brought the view controller class over to the new project.

3) Has something changed, since I started the larger project in XCode4 and iOS6 (although it works fine in XCode5 and iOS7)? And does it make a difference that the new project was started in XCode5.

4) I can get rid of the warnings by importing the destination view controller header, but I don't think I should have to when using respondsToSelector as the method setMilage: is in my project.

Any help to improve my understanding would be greatly appreciated. I am sure I have made a simple mistake somewhere, it is just frustrating as the code works without warnings in one project and not the other.

Thanks in advance.

p.s. As you would expect I also get the same warning at perfomSelector as well.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"setMilage:"]) {
        if ([segue.destinationViewController respondsToSelector:@selector(setMilage:)]) {
            [segue.destinationViewController performSelector:@selector(setMilage:) withObject:self.milage];
        }
    }
}

The full warning - Semantic Issue Undeclared selector 'setMilage:'

0

There are 0 answers