The problem is that your SecondViewController
has no relationship to the passNames
protocol (being declared in the same header does not count).
Since protocol methods need to be implemented (or their implementation be inherited from the base) and your SecondViewController
does not do that, you cannot call setAreaName:
without triggering an error.
If you would like to use a common protocol in two view controllers, you need to do this:
- Give
passNames
protocol a more conventional name that starts in a capital letter, and put it in a separate header file - Include that header in both view controllers (the
#import "SecondViewController.h"
in theFirstTableViewController.h
does not look right) - Put implementations of
setAreaName:
in both view controllers.
Note that you cannot put the common functionality in a superclass, because your view controllers inherit from different bases (i.e. UIViewController
and UITableViewController
).