As per the Realm Documentation, CGFloat is not one of the types supported in Realm. So I have a Person Storage class as follows:-
class Person: Object {
@objc dynamic var height: Float = 0.0
@objc dynamic var weight: CGFloat = 5.0
override var description: String {
return " { Height = \(height), Weight = \(weight)}"
}
}
I know till the object of Person Class is added to realm, It will behave as normal swift object and will not be managed by Realm. Once it is added to the realm, Realm will manage it. So it will compile successfully.
Now I am adding the object to the realm, and then printing it.
let person = Person()
try! realm.write {
realm.add(person)
}
print(realm.objects(Person.self).first)
It is printing Optional( { Height = 0.0, Weight = 5.0})
As per my understanding, since type CGFloat is not supported by Realm, it should crash at runtime when I am adding object to Realm.
So what is going under the hoods here? Also which Type is being used to save CGFloat value?