Upgrading from Realm 0.95.3 to Realm 0.96.3
Application errors out inside RLMObjectStore.mm:106
Throws error stating the properties have been made optional
(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;
}
}
How can these be made non optional again i do not see anything in the documentation on how to do this. Model is configured as below:
#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 file is as follows.
#import "DTFLogMessage.h"
@implementation DTFLogMessage
+ (NSString*)primaryKey
{
return @"id";
}
@end
Realm's Objective-C docs on Optional Properties explains how to do this:
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