我有一个Product
带有标题的模型:
@interface Product : RLMObject <NSCopying,NSCoding>
{
}
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *thumbnailURL;
@property (nonatomic, strong) UIImage *thumbnail;
-(id)initWithInfo:(NSDictionary*)dictionary;
-(UIImage*)getThumbnail;
和实施:
@implementation Product
-(id)initWithInfo:(NSDictionary*)dictionary
{
self = [self init];
if (self) {
_title = dictionary[@"title"];
_thumbnailURL = dictionary[@"thumbnailURL"];
_thumbnail = [self getThumbnail];
}
return self;
}
-(UIImage*)getThumbnail
{
if (_thumbnail) {
return _thumbnail;
}
//load image from cache
return [self loadImageFromCache];
}
现在,当我尝试创建一个Product
对象并将其插入时Realm
,我总是得到异常
[RLMStandalone_Product getThumbnail]: unrecognized selector sent to instance 0xcd848f0'
现在,我删除_thumbnail = [self getThumbnail];
它,它工作正常。但后来我得到另一个例外
[RLMStandalone_Product title]: unrecognized selector sent to instance 0xd06d5f0'
当我重新加载我的视图时。我已经Product
在主线程中创建了我的对象,所以使用它的属性和方法应该没问题,不是吗?
任何建议将被认真考虑!