![](/img/trans.png)
[英]Implicit Conversion from Objective-C Pointer to int * is Disallowed With ARC
[英]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
然后,因為我想在其他控制器中訪問swaipView
和cateItem
,所以我認為可以將它們移動到.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.