-2

I have a very simple bit of code. I suspect that most part of it is unrelated, but as I'm completely puzzled about this problem, I decided to include the source as is.

GQEncounter.h:

#import <Foundation/Foundation.h>
#import "GQEncounterViewController.h"

@interface GQEncounter : NSObject {
    NSArray *roughOptions;
    NSString *roughText;
}

@property (readonly) NSArray *options;
@property (readonly) NSString *text;

- (id) initFromDictionary:(NSDictionary *) dict;
- (void) executeOption:(NSInteger) number;

@end

GQEncounterViewController.h:

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

@interface GQEncounterViewController : UIViewController {

    GQEncounter *_encounter;
    UILabel *encounterText;
    NSArray *encounterButtons;
    CGRect _rect;

}

- (id)initWithEncounter:(GQEncounter *)encounter
                   rect:(CGRect)rect;
- (void)chooseOption:(UIButton *)button;

@end

As you can see, it's really simple. But, for some unknown reason, xcode shows errors in GQEncounterViewController file: "Unknown type name 'GQEncounter'" at declaration of _encounter variable, and "Expected a type" at initWithEncounter declaration. It is as if GQEncounter isn't included in the file at all. I use xcode 4.4.1. I even re-installed it trying to get rid of this problem, but it didn't help.

What is happenning here?

Max Yankov
  • 12,551
  • 12
  • 67
  • 135
  • 1
    possible duplicate of [Objective-C header file not recognizing custom object as a type](http://stackoverflow.com/questions/7896440/objective-c-header-file-not-recognizing-custom-object-as-a-type); also [Import in ObjC --- Am I doing this wrong?](http://stackoverflow.com/questions/7091778/import-in-objective-c-am-i-doing-this-wrong) and [Import loop](http://stackoverflow.com/questions/1223914/objective-c-import-loop) – jscs Aug 21 '12 at 18:19

1 Answers1

2

I'm not sure why you have GQEncounterViewController import statement in the GQEncounter.h file but try to move it out and if you really need it, use @class GQEncounterViewController; instead

Sash Zats
  • 5,376
  • 2
  • 28
  • 42