Search code examples
iosobjective-cxcodeuipageviewcontroller

Cannot find protocol declaration for 'MapViewControllerDelegate'; did you mean 'UIPageViewControllerDelegate'?


I have an App has written in objective C and I uploaded a new version of it before 2 months and everything was working perfectly, now I want to add some things but I get this error: Cannot find protocol declaration for MapViewControllerDelegate; did you mean UIPageViewControllerDelegate?

#import <UIKit/UIKit.h>

@protocol MapViewControllerDelegate <NSObject>

-(void)closeViewController;

@end

@interface RoomServiceViewController : UIViewController
@property (weak,nonatomic) id <MapViewControllerDelegate> delegate;

@end

Cannot find protocol declaration for MapViewControllerDelegate; did you mean UIPageViewControllerDelegate?

Replace MapViewControllerDelegate with UIPageViewControllerDelegate

Reference to MapViewControllerDelegate is ambiguous


Solution

  • Since you tagged UIPageViewController and XCode is your type confusing with UIPageViewControllerDelegate: Do you have an UIPageViewController somewhere that is also referring to your protocol?

    If yes: Objective-C types aren't automatically known in your project. You need to include their header files. Else you get funny best guesses.

    Another option. Move the protocol to a separate headerfile and see if this clears thing up.

    Also if you used include instead of import you end up with odd compiler errors.