从 0.95.3 升级到 0.96.3 Cocoa 领域,获得 "Property 'id' has been made optional."
Upgraded from 0.95.3 to 0.96.3 Cocoa Realm, getting "Property 'id' has been made optional."
正在从领域 0.95.3 升级到领域 0.96.3
内部应用程序错误 RLMObjectStore.mm:106
抛出错误,指出属性已设为可选
(lldb) po objectSchema
DTFLogMessage {
id {
type = string;
objectClassName = (null);
indexed = YES;
isPrimary = YES;
optional = YES;
}
creationDate {
type = date;
objectClassName = (null);
indexed = NO;
isPrimary = NO;
optional = YES;
}
message {
type = string;
objectClassName = (null);
indexed = NO;
isPrimary = NO;
optional = YES;
}
fileinfo {
type = string;
objectClassName = (null);
indexed = NO;
isPrimary = NO;
optional = YES;
}
type {
type = int;
objectClassName = (null);
indexed = NO;
isPrimary = NO;
optional = NO;
}
}
如何使这些再次成为非可选的?我在文档中没有看到任何关于如何做到这一点的内容。模型配置如下:
#import <Realm/RLMObject.h>
@interface DTFLogMessage : RLMObject
@property NSString *id;
@property NSDate *creationDate;
@property NSString *message;
@property NSString *fileinfo;
@property NSInteger type;
@end
RLM_ARRAY_TYPE(DTFLogMessage)
.m文件如下
#import "DTFLogMessage.h"
@implementation DTFLogMessage
+ (NSString*)primaryKey
{
return @"id";
}
@end
Realm 在 Optional Properties 上的 Objective-C 文档解释了如何执行此操作:
By default, NSString *
, NSData *
, and NSDate *
properties allow you to set them to nil. If you want to require that a value be present, you can override the +requiredProperties
method on your RLMObject subclass. For example, with the following model definition, trying to set the person’s name to nil will throw an exception, but setting their birthday to nil is allowed:
@interface Person : RLMObject
@property NSString *name;
@property NSDate *birthday;
@end
@implementation Person
+ (NSArray *)requiredProperties {
return @[@"name"];
}
@end
正在从领域 0.95.3 升级到领域 0.96.3
内部应用程序错误 RLMObjectStore.mm:106
抛出错误,指出属性已设为可选
(lldb) po objectSchema
DTFLogMessage {
id {
type = string;
objectClassName = (null);
indexed = YES;
isPrimary = YES;
optional = YES;
}
creationDate {
type = date;
objectClassName = (null);
indexed = NO;
isPrimary = NO;
optional = YES;
}
message {
type = string;
objectClassName = (null);
indexed = NO;
isPrimary = NO;
optional = YES;
}
fileinfo {
type = string;
objectClassName = (null);
indexed = NO;
isPrimary = NO;
optional = YES;
}
type {
type = int;
objectClassName = (null);
indexed = NO;
isPrimary = NO;
optional = NO;
}
}
如何使这些再次成为非可选的?我在文档中没有看到任何关于如何做到这一点的内容。模型配置如下:
#import <Realm/RLMObject.h>
@interface DTFLogMessage : RLMObject
@property NSString *id;
@property NSDate *creationDate;
@property NSString *message;
@property NSString *fileinfo;
@property NSInteger type;
@end
RLM_ARRAY_TYPE(DTFLogMessage)
.m文件如下
#import "DTFLogMessage.h"
@implementation DTFLogMessage
+ (NSString*)primaryKey
{
return @"id";
}
@end
Realm 在 Optional Properties 上的 Objective-C 文档解释了如何执行此操作:
By default,
NSString *
,NSData *
, andNSDate *
properties allow you to set them to nil. If you want to require that a value be present, you can override the+requiredProperties
method on your RLMObject subclass. For example, with the following model definition, trying to set the person’s name to nil will throw an exception, but setting their birthday to nil is allowed:
@interface Person : RLMObject
@property NSString *name;
@property NSDate *birthday;
@end
@implementation Person
+ (NSArray *)requiredProperties {
return @[@"name"];
}
@end