0

I am stuck with this problem. I have the following .h file:

#import <UIKit/UIKit.h>

@protocol MapSettingsViewDelegate

- (void)settingsDidUpdate:(BOOL)scheme;

@end

@interface MapSettingsViewController : UIViewController

@property (nonatomic, assign) id <MapSettingsViewDelegate> delegate;
@property (nonatomic, strong) IBOutlet UINavigationBar *navBar;
@property (nonatomic, strong) IBOutlet UINavigationItem *titleItem;
@property (nonatomic, strong) IBOutlet UITableView *TableView;

- (id)init;
- (IBAction)saveAction:(id)sender;

@end

When I declare the following:

@interface MapViewController : UIViewController <MapSettingsViewDelegate>

The compiler complains with the following message:

Cannot find protocol declaration for 'MapSettingsViewDelegate'

I have the same kind of delegate declaration in other files in the same project that are compiled without a glitch. I spent the last four hours trying to figuring out what I am doing wrong. Cleaning the project does not nothing.

Eduardo Mauro
  • 1,515
  • 1
  • 26
  • 38
  • 2
    Did you import the .h? – sidyll Apr 30 '13 at 15:39
  • @Eduardo Mauro,I'm trying to help you, Could you please tell me all the #import's in MapViewController.h and MapSettingsViewController.h file – Thilina Chamath Hewagama Apr 30 '13 at 16:03
  • @ThilinaHewagama all includes of MapSettingsViewController are above. Just UIKit. In MapViewController are included those headers: "MapSettingsViewController.h" "PlacemarkSelectionViewController.h" "PopoverView.h" – Eduardo Mauro Apr 30 '13 at 16:04
  • Another information: even if I include a syntax error in MavSettingsViewController, XCode keep complaining with the same error message. The corresponding .m file is not compiled. – Eduardo Mauro Apr 30 '13 at 16:08
  • 3
    Show us the actual imports. I've got a shiny $1 bill that says they're circular. – Chuck Apr 30 '13 at 16:59
  • Thanks @Chuck, pointed in the correct direction. See my answer below. – Eduardo Mauro Apr 30 '13 at 17:47

3 Answers3

0

Problem solved. As suggested in this answer, I created a new class with a different name and copied all coded from the previous class. Worked flawlessly. It seems XCode lost track of something.

Community
  • 1
  • 1
Eduardo Mauro
  • 1,515
  • 1
  • 26
  • 38
0

You are running into preprocessor problems. Both of your classes import each other. I think you can solve this by adding @class below your protocol declaration as shown below; and moving your #import "mapViewController.h" line into MapSettingsViewController.m file. The @class tells the compiler that you will include the class content somewhere else (in the .m file).

Note that, on the top of your MapViewController.h class file you can include #import "MapSettingsViewController.h" just like normal. Hope this help. I ran into the same problem myself earlier.

#import <UIKit/UIKit.h>

@protocol MapSettingsViewDelegate

- (void)settingsDidUpdate:(BOOL)scheme;

@end

@class MapViewController 

@interface MapSettingsViewController : UIViewController

@property (nonatomic, assign) id <MapSettingsViewDelegate> delegate;
...
...
Ohmy
  • 2,201
  • 21
  • 24
-2

Import the MapSettingsViewController.h file

William Falcon
  • 9,813
  • 14
  • 67
  • 110