3

In one class I have the following AlertEditorContainerViewController.m

    #import "AlertEditorContainerViewController.h"

    @interface AlertEditorContainerViewController ()
    -(void)swapViewControllers;
    @end

    @implementation AlertEditorContainerViewController

    @synthesize currentSegueIdentifier;
    @synthesize segIndex;

   - (void)swapViewControllers
   {
       self.currentSegueIdentifier = ([self.currentSegueIdentifier  isEqual: SegueIdentifierFirst]) ? SegueIdentifierSecond : SegueIdentifierFirst;
       [self performSegueWithIdentifier:self.currentSegueIdentifier sender:nil];
   }
    @end

The in another class I try to call it AlertEditorViewController.h

    @interface AlertEditorViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
    { 
          AlertEditorContainerViewController              *containerViewController;

     }

AlertEditorViewController.h #import "AlertEditorViewController.h"

    @implementation AlertEditorViewController
    - (IBAction)segmentSwitchValueChanged:(id)sender
    {
          [containerViewController swapViewControllers];    
    }
    @end

This gives the error "No visible @interface for AlertEditorContainerViewController declares the selector swapViewControllers'

I have looked up all of the other similar queries and they all seem to point at typos etc which I can't find in my code.

esqew
  • 42,425
  • 27
  • 92
  • 132
Carl Gilbert
  • 65
  • 1
  • 7

1 Answers1

2

Declare -(void)swapViewControllers in your AlertEditorContainerViewController.h file, not your .m file.

For information on this problem, you'll want to check out this Stack Overflow question, but in short, by declaring the method within the @interface block located in your .m file, you're effectively making it a private method (inaccessible by other implementation files). From the link:

The interface section in the implementation file allows you to declare variables, properties, and methods that are private, meaning that they won't be seen by other classes.

The compiler knows it's there within the scope of that particular file, but other files can't access or even see that method as being defined.

Community
  • 1
  • 1
esqew
  • 42,425
  • 27
  • 92
  • 132