Previously i posted a question in SO, without knowing what caused this error. Later i created a new project and re-created the error. Here’s what it says;
I am getting an error called Unknown type name Exam. I have a question posted under a different heading. But now i found what the problem is (SO i created another question, hope people will not object this move, and provide me a solution to my problem 🙂 )
I created a fresh project to find what went wrong.
I created a NSObject class called Exam.
in the AppDelegate.h i added the following;
#import <UIKit/UIKit.h>
#import "Exam.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>{
Exam *ex;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) Exam *ex;
@property (strong, nonatomic) UITabBarController *tabBarController;
@end
in AppDelegate.m i have only synthesis ex, so i am not pasting that code here.
Now in the Exam class (NSObject class), i have the following code;
#import "AppDelegate.h"
#import <Foundation/Foundation.h>
@interface Exam : NSObject {
AppDelegate*APP; <-- here i get Unknown type AppDelegate.
}
@end
As soon as i create the AppDelegate object here, i get the errors.
note: I am using ARC
change Exam.h to
then your Exam.m above
@implementationdo thisCurrently you are importing Exam.h in Appdelgate.h and AppDelegate.h in Exam.h ..this makes both the classes import each other before executing itself.. which cause compiler errors..since each class refers to the other..