4

I'm unsure what is going on or what I changed, but all of a sudden a class I'm trying to reference "that is in the project tree" and in the folder (when I "show in finder") isn't being read at all ... I get multiple errors on the same line of code [see attached].

enter image description here

Please Help!!!


The issue occurs when I try to import HomeViewController.h into my MainContainerViewController

Works:

#import <UIKit/UIKit.h>
#import "ViewController.h"

@interface MainContainerViewController : UIViewController {

ViewController *parent;

NSString *FACING;
IBOutlet UIView *container;

IBOutlet UIView *topNav;

IBOutlet UIButton *homeBTN;
IBOutlet UIImageView *homeImg;
IBOutlet UILabel *homeLabel;
IBOutlet UIImageView *seperator1;
IBOutlet UIButton *bookmarksBTN;
IBOutlet UIImageView *bookmarksImg;
IBOutlet UILabel *bookmarksLabel;
IBOutlet UIImageView *seperator2;
IBOutlet UIButton *favouritesBTN;
IBOutlet UIImageView *favouritesImg;
IBOutlet UILabel *favouritesLabel;
IBOutlet UIImageView *seperator3;
IBOutlet UIButton *notesBTN;
IBOutlet UIImageView *notesImg;
IBOutlet UILabel *notesLabel;
IBOutlet UIImageView *seperator4;
IBOutlet UIButton *fontBTN;
IBOutlet UIImageView *fontImg;
IBOutlet UILabel *fontLabel;
IBOutlet UIImageView *seperator5;
IBOutlet UIButton *settingsBTN;
IBOutlet UIImageView *settingsImg;
IBOutlet UILabel *settingsLabel;

NSString *drawerIsAnimating;

//SETTINGS (LOCAL)
NSString *fontSize;

etc.

Broken:

#import <UIKit/UIKit.h>
#import "ViewController.h"
#import "HomeViewController.h"

@interface MainContainerViewController : UIViewController {

ViewController *parent;

NSString *FACING;
IBOutlet UIView *container;

IBOutlet UIView *topNav;

IBOutlet UIButton *homeBTN;
IBOutlet UIImageView *homeImg;
IBOutlet UILabel *homeLabel;
IBOutlet UIImageView *seperator1;
IBOutlet UIButton *bookmarksBTN;
IBOutlet UIImageView *bookmarksImg;
IBOutlet UILabel *bookmarksLabel;
IBOutlet UIImageView *seperator2;
IBOutlet UIButton *favouritesBTN;
IBOutlet UIImageView *favouritesImg;
IBOutlet UILabel *favouritesLabel;
IBOutlet UIImageView *seperator3;
IBOutlet UIButton *notesBTN;
IBOutlet UIImageView *notesImg;
IBOutlet UILabel *notesLabel;
IBOutlet UIImageView *seperator4;
IBOutlet UIButton *fontBTN;
IBOutlet UIImageView *fontImg;
IBOutlet UILabel *fontLabel;
IBOutlet UIImageView *seperator5;
IBOutlet UIButton *settingsBTN;
IBOutlet UIImageView *settingsImg;
IBOutlet UILabel *settingsLabel;

NSString *drawerIsAnimating;

//SETTINGS (LOCAL)
NSString *fontSize;

etc.

Chris Allinson
  • 1,837
  • 2
  • 26
  • 39
  • 1
    Please, avoid writing full sentences in caps. It's not only unpleasant to read, like EULA per example, it also means you're shouting at us. You can use styles if you need to hilite some parts of your question. – fabrice truillot de chambrier Jun 22 '12 at 20:30
  • Note that there is no error on the import statement, suggesting that the .h file was found OK. There's something preventing the class from being fully declared -- a misplaced semicolon, missing @end statement, etc. – Hot Licks Jun 22 '12 at 20:34

4 Answers4

8

You may have a header import cycle.

Add

@class MainContainerViewController2;

just before

@interface HomeViewController2

It should solve that particular issue.

As a rule of thumb, you shouldn't #import headers in headers if you do not have an absolute need to do so, ie. a superclass header. If you need to use a class, declare it with @class instead of importing the class header. Do that and you should be safe 99% of the time.

0

The file may not be included in the target you are building.

GBegen
  • 6,107
  • 3
  • 31
  • 52
0

Try to check MainContainerViewController2 target.

Click on MainContainerViewController2 .m and .xib and check in the Utilities panel (View > Utilities > Show File Inspector) if the checkbox is ticked into Target Membership section.

Phillip
  • 4,276
  • 7
  • 42
  • 74
0

First check VERY CAREFULLY your MainContainerViewController2.h file to see if there are any wayward characters anywhere in the file.

Hot Licks
  • 47,103
  • 17
  • 93
  • 151