I try to import as very little as possible in my header files (using the implementation file instead), and for classes we can use @class, but what about protocols? If I try to declare a protocol that I’ll be using in that header with @protocol I get a warning that “Cannot find protocol definition for ‘…'”
Is the proper way to handle this simply by importing the header that does the protocol declaration? (so one .h file imports the other .h)
Example for ListViewController.h:
#import <UIKit/UIKit.h>
#import "JTRevealSidebarV2Delegate.h" // is this the best way?
@class List;
@protocol JTRevealSidebarV2Delegate; // this produces a warning.
@interface ListViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, JTRevealSidebarV2Delegate>
It’s correct, but if you want to get picky you can always create a single .h file where you declare your protocol only, and have both your
ListViewControllerandJTRevealSidebarV2Delegateimport it