2

I am sure this is really dumb, but I just cant seem to understand why am I getting this error. In my project I have a view controller and another class that does some data structuring job (not relevant anyway). I am getting a compilation error: "unknown type name "the view controller"" when trying to instantiate it within my class.

This is my class .h:

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#import "MyLocationController.h"
#import "GetZip.h"
#import "SecondTab.h"

 @interface DataEngine : NSObject <MyLocationControllerDelegate, MKMapViewDelegate, GetZipcodeDelegate> {

MyLocationController *CLController;
GetZip *getzip;
SecondTab *secondTab; //ERROR IS HERE

}

My view controller .h:

#import <UIKit/UIKit.h>
#import "FirstTab.h"
#import "DataEngine.h"

@interface SecondTab : UIViewController <UITableViewDelegate, UITableViewDataSource> {

IBOutlet UITableView *table1;
NSString *address; 
NSDate *time;
NSDictionary *dataDict;
  DataEngine *fullData;

}

(I omitted all the @synthesis since I dont think they matter...in any case, I do @property (nonatomic, retain) for everything).

Any idea what can go wrong here?

TommyG
  • 4,145
  • 10
  • 42
  • 66

1 Answers1

7

Why don't you try to forward declare it. Use @class secondTab instead of #import secondTab? It will help avoiding any circular inclusions if thats the problem.

Manish Burman
  • 3,069
  • 2
  • 30
  • 35
  • +1 Thanks, Manish. That has seemed to be doing the job! Any idea what could have gone wrong? (whats the diff between @class and #import anyway? :/). – TommyG Aug 15 '11 at 17:28
  • 1
    http://stackoverflow.com/questions/322597/class-vs-import You might have had a circular dependency where both classes rely on each other. In any case, Tommy, its always good to use a forward declaration to avoid these issues. – Manish Burman Aug 15 '11 at 17:30
  • Now I cant seem to allow + init SecondTab though...is this expected? – TommyG Aug 15 '11 at 17:31
  • You'll need to import SecondTab in your implementation file (the .m file) – Manish Burman Aug 15 '11 at 17:32