在RealmSwift 3.21.0中,我在name: "services"
和child = { value: 0x0, label: "services" }
的Realm的Object.swift文件中遇到此崩溃:
private static func getOptionalPropertyMetadata(
for child: Mirror.Child,
at index: Int
) -> RLMSwiftPropertyMetadata? {
guard let name = child.label else {
return nil
}
>>> let mirror = Mirror(reflecting: child.value) //Thread 13: EXC_BAD_ACCESS (code=1, address=0x0)
let type = mirror.subjectType
let code: PropertyType
对于此模型:
class RealmAppointment: Object, Codable {
override static func primaryKey() -> String {
return CodingKeys.id.stringValue
}
@objc dynamic var id: String
@objc dynamic var startAt: Date
@objc dynamic var createdAt: Date! = Date()
@objc dynamic var updatedAt: Date! = Date()
let services = List<String>() // var also doesn't work
}
奇怪的是,我在另一个Realm对象上以相同的方式定义了服务,并且它的工作原理是:
public class RealmOffer: Object, Codable {
override public static func primaryKey() -> String {
return CodingKeys.id.stringValue
}
static let updatedAtKey = CodingKeys.updatedAt.stringValue
@objc dynamic public var id: String?
@objc dynamic public var startAt: Date! = Date()
@objc dynamic public var createdAt: Date! = Date()
@objc dynamic public var updatedAt: Date! = Date()
public var services = List<String>()
}
有什么想法吗?
答案 0 :(得分:0)
很奇怪,更改了RealmAppointment.services的定义,
let services = List<String>()
到
let services: List<String>! = List<String>()
修复了此崩溃。