Xcode不再识别对象

时间:2015-02-09 14:11:19

标签: ios xcode nsobject

我有一个名为friend的对象(我知道,第一个字母应该是大写的)。我在许多其他类中使用此类并查看控制器。

突然间,在没有更改任何代码的情况下,我拥有的每个自定义对象都停止了相互识别。我总是得到错误未知类型名称“朋友”。

我已经尝试清除项目并重启mac。 WTF错误的Xcode?我的整个项目突然停止了工作。

这是我的班级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

1 个答案:

答案 0 :(得分: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中的ivar,你不需要界面中的那些(它们可以在@implimentation行之后进入一个块),除非你需要它们以便向后兼容......