MJVDM
MJVDM

Reputation: 3963

Cannot find protocol declaration when protocol is declared in its own .h file

I created a protocol

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

// Defines the protocol that must be implemented to be a delegate for UCMapviewController
@protocol UCMapviewDelegate <NSObject>
@required
- (void)pushMapviewRight;

@end

When I go to new file -> protocol, there is a prompt which asks for the target. I check my project. But when i click the protocol.h file in my project and look at file inspector, at "Target membership", my project is unchecked and I cannot check it.

I don't get this error when I put the protocol in the header file of one of my viewControllers (for example). Do I have to import the protocol somewhere else?

WHat is wrong? Help is greatly appreciated! thx

Upvotes: 0

Views: 1419

Answers (1)

Lily Ballard
Lily Ballard

Reputation: 185841

Header files don't go into a target, unless you're building a framework and want to copy the header file into the Headers folder in the framework. When building an app, only source files belong to the target.

You'll notice that if you select one of your other headers in your project, it will also not be in the target. Only the corresponding source file will be. This won't matter. If the header is in your project, you can #import it just fine.

Upvotes: 2

Related Questions