2012-09-05 145 views
4

Xcode中已經顯示出藍色的這個錯誤: 「未知類型名稱」知道的未知類型名稱?

我會解釋: 我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 

在我Stories.h:

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

@interface Stories : UIDocument 


@property (strong) NSString * storyContent; 

@end 

再次,突然間。

在此先感謝。

編輯:

在我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拋出的ARC問題負載。

我已經刪除了無用的引用ViewController.h,工作。 解決!

+0

什麼是ViewController.h? – Darren

回答

12

您有circular reference問題。

發生了什麼事是,當你加載ViewController它通過它的進口,它加載Stories.h,它會加載它的進口,它可以追溯到ViewController.h,所以你是停留在一個無限循環出現。

要麼刪除衝突進口中的一個,或者使用forward class declaration(即例如是用於C++,見here用於與目標C的一例)

+0

同樣,@class在使用屬性時會引發很多錯誤。有沒有辦法使用#import解決它? –

+0

你不能移除'Stories'中的#import ViewController.h嗎?你用它做什麼?使用'@ class'時會拋出什麼錯誤? – jere

+0

你真棒..我很沮喪,這個錯誤..非常感謝 –