2015-02-09 160 views
1

我有一個名爲friend的對象(我知道,第一個字母應該是大寫)。我在許多其他類和視圖控制器中使用這個類。Xcode不再識別對象

突然間,沒有改變任何代碼,我擁有的每個自定義對象,都停止認出對方。我總是得到錯誤未知類型名稱「朋友」。

我已經嘗試清除項目並重新啓動mac。 這個Xcode的WTF是錯誤的?突然之間,我的整個項目都停止了。

這裏是我的類currentUser.h

#import <Foundation/Foundation.h> 
#import "friend.h" 

@interface currentUser : NSObject<NSCoding> 
{ 
    BOOL fromfacebook; 
    @private 
    NSMutableArray *upLoadStack; 

} 

@property (nonatomic,strong)NSString *token; 
@property (nonatomic,strong)NSString *email; 
@property (nonatomic,strong)NSString *name; 
@property (nonatomic,strong)UIImage *userImg; 
@property (nonatomic,strong)NSString *username; 
@property (nonatomic,strong)NSString *facebookID; 
@property (nonatomic,strong)NSString *userPSW; 
@property (nonatomic,strong)NSString *userID; 
@property (nonatomic,strong)NSMutableArray *friendsList; 
@property (nonatomic,strong)NSMutableArray *groups; 
@property (nonatomic,strong)NSData *audioMessage; 
@property (nonatomic,strong)NSMutableArray *mimosToDownload; 
@property (nonatomic,strong)NSMutableArray *mimosDownloaded; 
@property (nonatomic,strong)friend *friendToSend; //Here is where a I get the error of unknown type name 


@end 

這是friend.h

#import <Foundation/Foundation.h> 
#import "currentUser.h" 
#import "Imager.h" 

@interface friend : NSObject<NSCoding> 

@property (nonatomic,strong)NSString *username; 
@property (nonatomic,strong)NSString *userID; 
@property (nonatomic,strong)UIImage *userImg; 
@property(nonatomic,strong)NSMutableData *buffer; 

@property(nonatomic)BOOL flagDownloaded; 
-(UIImage*)downloadImageBlocked; 
-(id)init; 
-(UIImage*)getFriendImg; 
-(UIImage*)userImg; 
-(NSString*)getUserID; 
-(NSString*)getUserName; 
- (void)encodeWithCoder:(NSCoder *)encoder; 
-(bool)isNil; 

@end 

回答

2

解決這個問題,你知道錯了第一的東西...

變化

@interface currentUser : NSObject<NSCoding> 
{ 
    BOOL fromfacebook; 
    @private 
    NSMutableArray *upLoadStack; 

} 

@interface User : NSObject<NSCoding> 
{ 
    BOOL fromfacebook; 
    @private 
    NSMutableArray *upLoadStack; 

} 

您不需要知道用戶是否最新,用戶是否具有用戶的屬性,將他們視爲實際表示對象。

變化:

@interface friend : NSObject<NSCoding> 

@interface Friend : NSObject<NSCoding> 
你知道它是錯的

,現在解決它,你必須解決它在1000個名額,而不是100位之前。

公約在Objective-C中非常重要。

也不會導入到一切你的頭,如果你不需要......

@class Friend; //forward class declaration 

@interface currentUser : NSObject<NSCoding> 
... 
@property (nonatomic,strong)Friend *friendToSend; //Here is where a I get the error of unknown type name 

,併爲您的伊娃在currentUser你不需要那些在接口(他們可以去在@implimentation行之後的一個塊中),除非你需要它們來向後兼容...

+0

它工作!謝謝,問題是這是一箇舊項目,當我開始在Objective-C中編程時,我會更加關注這些細節。 – 2015-02-09 14:44:51