XCode中互相包含引起的"property with 'retain(or strong)' attribute must be of object type

虽然说XCode的#import比#include的好处是解决多重包含的问题,但是今天还是遇到了互相包含头文件中产生

property with 'retain(or strong)' attribute must be of object type”

这个错误。

解决方式很简单:

在相关的头文件中加入

@class "xxxx"

就能解决。

如:
#import <Foundation/Foundation.h>
#import "Project.h"
#import "Member.h"

@class Member;
@class Project;

@interface Day : NSObject{

    ...
}
@end

跟C++不一样的地方是,出现这个问题时,我们不需要删除发生问题的#import “xxx”这个头文件。

猜你喜欢

转载自iaiai.iteye.com/blog/2315220
今日推荐