Search code examples
iphoneuisplitviewcontroller

UISplitViewController selector not recognized from MasterViewController


I have a custom UISplitViewController, created so I can present a login screen to the user. In this controller I also have a logout method.

The logout button is in the navigation bar of the MasterViewController. When the user clicks logout, I am trying to call the UISplitViewControllers logoutUser method. First I tried:

[self.splitViewController logoutUser:self];

This gave errors when trying to compile:

No visible @interface for 'UISplitViewController' declares the selector 'logoutUser:' I then commented out the offending line and added the following if, checking to see if indeed my UISplitViewController responds to the selector.

if([self.splitViewController respondsToSelector:@selector(logoutUser:)]){
   // [self.splitViewController logoutUser:self];
    NSLog(@"Selector");
}else{
    NSLog(@"No Selector");
}

In the log when running I get Selector. uncommenting the [self.splitViewController logoutUser:self] I get the same error.

I tried to clean the build and rebuild but it still gives this error. How cna I resolve this issue?

Thanks, Bruce


Solution

  • As commented above, I found the answer:

     [self.splitViewController performSelector:@selector(logoutUser:) withObject:self];