Xcode has showed out of the blue this error: "Unknown type name"
I'll explain: My StoriesViewController.h:
#import <UIKit/UIKit.h>
#import "Stories.h"
@interface StoriesViewController : UIViewController <UITextViewDelegate>
@property (strong) Stories *story; //Here it goes- "Unknown type name `Stories`"
@property (weak) IBOutlet UITextView *storyView;
@end
In my Stories.h:
#import <UIKit/UIKit.h>
#import "ViewController.h"
@interface Stories : UIDocument
@property (strong) NSString * storyContent;
@end
Again, out of the blue.
Thanks in advance.
EDIT:
In my ViewController.h:
#import <UIKit/UIKit.h>
#import "Stories.h"
#import "StoriesViewController.h"
#import "StoriesPickerViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface ViewController : UIViewController <UITextFieldDelegate, UIAlertViewDelegate> {
}
@end
NB @class throws loads of ARC issues.
I have removed useless references to ViewController.h, worked. SOLVED!
You have a circular reference problem.
What's happening is that when you load your ViewController it goes through it's imports, it loads Stories.h, it goes to load it's imports and it goes back to ViewController.h, so you are stuck in an infinite loop there.
Either remove one of the conflicting imports, or use forward class declaration (that example is for C++, see here for an example with Objective-C)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With