In Chapter 1, pg. 29 there is the following code:
cell.textLabel?.text = person.value(forKeyPath: "name") as? String
With the accompanying blurb:
Why do you have to do this? As it turns out, NSManagedObject doesn’t know about the name attribute you defined in your Data Model, so there’s no way of accessing it directly with a property. The only way Core Data provides to read the value is key- value coding, commonly referred to as KVC.
Perhaps this intended to expose the reader to KVC since its used in many places in core data apparently but why not this code instead:
cell.textLabel?.text = person.name
It seems infinitely better since it’s not stringly typed and much clearer IMHO. Is there something wrong in doing it this way or this just a missed update of the changes in iOS 10?
Thanks so much,