In an iOS app, I’m defining my own protocol to use the delegate pattern among my custom view controllers. Which files should #import which other files? In other words, there are four files involved in my case:
MainViewController.h: Declares a protocol and a view controller than implements the protocolMainViewController.m: Implements the protocol methodsSecondaryViewController.h: Declares a delegate instance variable and property of typeid <Protocol>(with a forward declaration ofProtocol)SecondaryViewController.m: Uses the protocol method on the delegate
Which files should #import which others? I’d think the forward declaration in the second view controller’s header would be enough, but I get compile warnings/errors unless the second header or implementation imports the main header.
SecondaryViewController.m should import the header as it uses the protocol methods.