首页 > 其他分享 >XCode中互相包含引起的"property with 'retain(or strong)' attribute must be of object type

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

时间:2023-02-07 10:05:25浏览次数:38  
标签:头文件 attribute XCode Member import strong type class


虽然说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”这个头文件。


标签:头文件,attribute,XCode,Member,import,strong,type,class
From: https://blog.51cto.com/u_15955464/6041270

相关文章