I have app that stores tree structure in CoreData.
There is an ManagedObject, “Item”, and it has attributes:
- itemId (string)
- List item
- title (string)
- parentId (string)
- parent (relationship to Item)
- parentTitle (string)
parentId points to another Item object.
How do I make property parentTitle to be filled automatically with title of parent Item ?
While Martin’s suggestion is a good solution for derived values, my question on yours is, why would you want this? You are not manipulating the value from the parent at all, ever. Since you are just accessing it, access the parent directly via KVC such as:
The only time you would want to use the
keyPathsForValues...functionality is if you are changing something based on that value. If you are just accessing it, use KVC directly.