I am trying Realm(installed using pods). I am using Swift 3 with Xcode 8.1.
My code looks like this-
do {
let realm = try Realm()
let human = Human()
human.name = "Nikhil"
human.legs = 2
try realm.write {
realm.add(human)
}
let humans = realm.objects(Human.self)
for h in humans {
print("\(h.name)") //Here is breakpoint
}
} catch {
//
}
And then I do
(lldb) po h.name
""
(lldb) po h.value(forKey: "name")!
Nikhil
Why are properties not returning values but I can retrieve values by value(forKey:
?
As stated by @kishikawa katsumi -
Class properties should have been defined as
dynamic
.A big thanks to him for pointing that mistake.