我有一个 Controller ,其属性在.m文件中定义如下:

@interface ContentViewController ()<SwipeViewDataSource, SwipeViewDelegate>
@property (nonatomic, strong)  SwipeView *swipeView;
@property (nonatomic, strong) NSMutableArray *items;
@property (nonatomic, strong) CateItem *cateItem;
@end

然后,因为我想在其他 Controller 中访问swaipViewcateItem,所以我认为可以将它们移动到.h文件中是这样的:
@interface ContentViewController : UIViewController
@property (nonatomic, strong)  SwipeView *swipeView;
@property (nonatomic, strong) CateItem *cateItem;
@end

但是这样做之后,以前的工作代码如下:
   if([[CateItem allObjects] count ] != 0){
        self.cateItem = [CateItem allObjects][0];
    }

会这样抱怨:

objective-c - 将属性移动到.h文件后,ARC不允许将Objective-C指针隐式转换为 &#39;int *&#39;-LMLPHP

发生了什么以及如何解决?

根据评论的需要,这里是cateItem,它是一个领域模型(Domain Model)
#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

最佳答案

您需要在CateItem块上方的ContentViewController header 中添加@interface的前向声明:

@class CateItem;

否则,缺少有关CateItem类型的信息的编译器将属性的类型假定为int *

09-07 05:40