簡體   English   中英

將屬性移動到.h文件后,ARC不允許將Objective-C指針隱式轉換為“ int *”

[英]Implicit conversion of an Objective-C pointer to 'int *' is disallowed with ARC after move property to .h file

我有一個控制器,其屬性在.m文件中定義如下:

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

然后,因為我想在其他控制器中訪問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];
    }

會這樣抱怨:

在此處輸入圖片說明

發生了什么以及如何解決?

根據評論的需要,這里是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

您需要在@interface塊上方的ContentViewController頭中添加CateItem的前向聲明:

@class CateItem;

否則,缺少有關類型CateItem信息的編譯器將屬性的類型假定為int *

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM