What is the difference in behavior of using ignored properties and just using simple swift property?
I need to add properties to realm object which should not be save to DB. Realm provides "ignored properties" but if I just write properties with ordinary swift style, it should't be saved to DB. Is there difference in behavior?
// Ignored propery
class Person: Object {
dynamic var tmpID = 0
override static func ignoredProperties() -> [String] {
return ["tmpID"]
}
}
// Normal swift property
class Person: Object {
var tmpID = 0 // Realm supported class but with no dynamic
var myClassObj = MyCustomClass() // Class realm does not support
}
You seem to e comparing ignoredProperties
with these two things
dynamic
For the first kind, Realm seems to still store these in the database.
class MyObject: Object {
dynamic var string = ""
var normalString = ""
}
And the database:
This is because dynamic
is just a way to tell swift to use dynamic dispatch in the Objective-C runtime, which allows the properties to be updated dynamically at runtime.
For the second kind, Realm seems to ignore your custom classes that are not Realm Object
s.