How do I porting Realm data model from Objective-c to Swift like below property?
Objective-c
@property RLMArray<NSNumber *><RLMInt> *dates;
Swift (My solution but it's not working)
let dates = List<Int>()
Error
Fatal error: 'try:' expression unexpectedly raised an error. Error Domain=io:realm Code=10 "Migration is required due to the following errors. - Property 'MyDataModel.dates' has been made required."
I found that I just had to add requiredProperties method on the RLMObject subclass in Objective-c version, and it will work fine in Swift version. The reason is that the List type must be non-optional.
+ (NSArray<NSString *> *)requiredProperties {
return @[@"dates"];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.