将Objective-C指针隐式转换为';int*';将属性移动到.h文件后,不允许使用ARC
我有一个控制器,其属性在将Objective-C指针隐式转换为';int*';将属性移动到.h文件后,不允许使用ARC,objective-c,types,compiler-errors,declared-property,Objective C,Types,Compiler Errors,Declared Property,我有一个控制器,其属性在.m文件中定义如下: @interface ContentViewController ()<SwipeViewDataSource, SwipeViewDelegate> @property (nonatomic, strong) SwipeView *swipeView; @property (nonatomic, strong) NSMutableArray *items; @property (nonatomic, strong) CateItem
.m
文件中定义如下:
@interface ContentViewController ()<SwipeViewDataSource, SwipeViewDelegate>
@property (nonatomic, strong) SwipeView *swipeView;
@property (nonatomic, strong) NSMutableArray *items;
@property (nonatomic, strong) CateItem *cateItem;
@end
但在这样做之后,以前的工作代码如下:
@interface ContentViewController : UIViewController
@property (nonatomic, strong) SwipeView *swipeView;
@property (nonatomic, strong) CateItem *cateItem;
@end
if([[CateItem allObjects] count ] != 0){
self.cateItem = [CateItem allObjects][0];
}
我会这样抱怨:
@interface ContentViewController : UIViewController
@property (nonatomic, strong) SwipeView *swipeView;
@property (nonatomic, strong) CateItem *cateItem;
@end
if([[CateItem allObjects] count ] != 0){
self.cateItem = [CateItem allObjects][0];
}
发生了什么,如何解决
这里的注释要求的是cateItem
,它是一个领域模型
#import <Foundation/Foundation.h>
#import <Realm/Realm.h>
@interface LivePhotoItem: RLMObject
@property NSString *image;
@property NSString *video;
@property NSString *fileid;
@property BOOL downloaded;
@end
RLM_ARRAY_TYPE(LivePhotoItem)
@interface CateItem: RLMObject
@property NSString *_id;
@property NSString *cateId;
@property NSString *category;
@property RLMArray<LivePhotoItem> *items;
@property NSString *cnName;
@end
#导入
#进口
@接口LivePhotoItem:RLMObject
@属性字符串*图像;
@属性字符串*视频;
@属性NSString*fileid;
@下载的财产档案;
@结束
RLM_阵列_类型(LivePhotoItem)
@接口类别项:RLMObject
@属性NSString*\u id;
@属性NSString*cateId;
@属性字符串*类别;
@Marray*项目的财产;
@属性NSString*cnName;
@结束
您需要在@界面
块上方的ContentViewController
标题中添加一个CateItem
的转发声明:
@class CateItem;
否则,编译器由于缺少有关类型
CateItem
的信息,会假定属性的类型为int*
您需要将CateItem
的前向声明添加到@interface
块上方的ContentViewController
头中:
@class CateItem;
否则,编译器由于缺少有关类型
CateItem
的信息,会假定属性的类型为int*
show CateItem interfaceHI,@kirander感谢您的回复,已编辑问题以显示CateItem
属性声明上也有警告,是吗?show CateItem Interface Hi,@kirander感谢您的回复,我已经编辑了这个问题以显示CateItem
您在CateItem
属性声明上也有一个警告,不是吗?