Is an unknown type name known yet?

Xcode showed this error: "Unknown type name"

I will 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, in 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 causes many problems with ARC.

I removed useless links to ViewController.h, worked. SOLVE!

+4
source share
1 answer

You have a circular link problem.

What happens when you load your ViewController , it goes through it, it loads Stories.h , it loads it, and it returns to ViewController.h , so you are stuck in an infinite loop there.

Either delete one of the conflicting imports, or use a direct class declaration (this example is for C ++, see here for an example with Objective-C)

+12
source

Source: https://habr.com/ru/post/1432499/


All Articles