I have a controller which has properties defined like this in .m
file:
@interface ContentViewController ()<SwipeViewDataSource, SwipeViewDelegate>
@property (nonatomic, strong) SwipeView *swipeView;
@property (nonatomic, strong) NSMutableArray *items;
@property (nonatomic, strong) CateItem *cateItem;
@end
Then because I want to access swaipView
and cateItem
in other controller so I think it's ok to move them to the .h
file like this:
@interface ContentViewController : UIViewController
@property (nonatomic, strong) SwipeView *swipeView;
@property (nonatomic, strong) CateItem *cateItem;
@end
But after doing that, previously working code like this:
if([[CateItem allObjects] count ] != 0){
self.cateItem = [CateItem allObjects][0];
}
will complain like this:
What happened and how to fix this?
as required by the comment here is the cateItem
, its a realm 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
You need to add a forward declaration of
CateItem
to theContentViewController
header above the@interface
block:Otherwise the compiler, lacking information about the type
CateItem
, assumes type of the property to beint *
.