【发布时间】:2020-07-29 21:50:14
【问题描述】:
我有一个对象,其来自服务器的属性之一需要类型为 UInt,一旦从服务器解析数据,我的项目使用 RealmSwift 在本地存储数据。
这是示例用例:
import RealmSwift
import Foundation
class MediaServerInfo: Object {
private var _hostPort = RealmOptional<UInt>()
}
// MARK: - Adopting to RealmOptionalType
// Here I am trying to adopt the protocol so that the _hostPort above can use RealmOptional<UInt>()
extension UInt: RealmOptionalType {
public static func className() -> String {
return "UInt"
}
}
但是,当我进入使用上述类的页面时,我会立即收到以下运行时错误:-
Terminating app due to uncaught exception 'RLMException', reason: ''RealmOptional<UInt>' is not a valid RealmOptional type.'
对此有什么想法吗?
【问题讨论】:
标签: ios swift realm realm-mobile-platform