.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