I cannot compile my iPhone project. In my CType.h I am getting the error:
Cannot find interface declaration for ‘NSObject’, superclass of
‘CType’.
This results in a lot of others errors which are also in the same header file.
I have read that this could be due to a circular reference in my project. Therefore, I have tried to change many of my header imports to forward declarations. There are still some which I have not managed to make a forward declaration yet (e.g. if the class inherits from another class, then it needs the import and if I am using a delegate. There probably is a way around this, though).
I have been searching through my project multiple times but I have not managed to find the circular reference. Is there any tips or tricks to find a circular reference? I thought it would have something to do with my CType but it does not seem so.
EDIT:
This is my CType:
Interface:
#import <Foundation/Foundation.h>
@interface CType : NSObject
/*
* Type ID
*/
@property (nonatomic, assign) NSInteger typeId;
/*
* Type
*/
@property (nonatomic, strong) NSString *type;
/*
* Initialize with type ID and type
*/
- (id)initWithId:(NSInteger)typeId type:(NSString *)type;
/*
* Type with type ID and type
*/
+ (CType *)typeWithId:(NSInteger)typeId type:(NSString *)type;
@end
Implementation:
#import "CType.h"
@implementation CType
/* Create setters and getters */
@synthesize typeId;
@synthesize type;
/* Initialize with type ID and type */
- (id)initWithId:(NSInteger)_typeId type:(NSString *)_type
{
if (self = [super init])
{
self.typeId = _typeId;
self.type = _type;
}
return self;
}
/* Type with type ID and type */
+ (CType *)typeWithId:(NSInteger)typeId type:(NSString *)type
{
return [[CType alloc] initWithId:typeId type:type];
}
@end
I tend to agree with @Hot Licks. This could very well be a corrupted file or a misconfiguration because theoretically there is nothing wrong with your code.
This is what I would suggest:
Create a new class (named something other than CType) and migrate your code over from CType to the new class. Then delete your old CType files. If things work at that point then rename your new class to CType and see what happens. Also, double check your apps prefix.pch file to see what headers are imported in there.