I need to implement a protocol in my User model, which need to have some special properties. But I'd like to avoid them to be stored/persisted in Realm database.
I didn't see in the documentation if there was a keyword for this. Did there is a trick to avoid saving some properties ?
public final class User: Object, Mappable, AvatarImageViewDataSource {
dynamic var id: Int = 0
dynamic var desc: String? = nil
dynamic var email: String? = nil
dynamic var firstName: String? = nil
dynamic var lastName: String? = nil
...
public var myPropertyIDontWantToSave: String? = nil // I don't want this to be stored
Check out the RealmSwift docs about Ignoring properties. There is some sample code included on that section:
class Person: Object {
dynamic var tmpID = 0
var name: String { // read-only properties are automatically ignored
return "\(firstName) \(lastName)"
}
dynamic var firstName = ""
dynamic var lastName = ""
override static func ignoredProperties() -> [String] {
return ["tmpID"]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With