我正在使用 Realm 0.92.3,但是当我有空值时它崩溃了,尽管我已经设置了默认属性。有什么解决方案吗?如果不是,我可能会使用 coredata 进行转换,因为这对我来说非常重要。null 在几个属性上是随机的
@interface WatchlistNews : RLMObject
@property NSString *nid;
@property NSString *tid;
@property NSString *country;
@end
@implementation WatchlistNews
+ (NSString *)primaryKey {
return @"nid";
}
+ (NSDictionary *)defaultPropertyValues {
return @{@"nid" : @"", @"tid": @"", @"country": @""};
}
@end
数据回复:
nid = 509319;
tid = <null>;
country = my;
错误代码:
-[NSNull UTF8String]: unrecognized selector sent to instance 0x10712b4c0
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull UTF8String]: unrecognized selector sent to instance 0x10712b4c0'