Question

I recently started programming with xCode and PyObjC and I'm trying to create a logistics application. I have a table with the store's items and a second table with the expenses. Until now everything worked ok by using just the interface builder to link values to core data information and I didn't have to write any code. Now the problem is that I have an attribute "cost" in the expenses table which should not be entered by the user. Instead it has to be calculated internally the instance the user enters the number of items of the transaction. Furthermore I want the number of those items to be added to the amount of the items in the storage.
Here is a graphic view of my problem.
Also, if this is possible when the user enters a value in the "number" column it will be great (to get rid of the "insert" button. Thanks a lot in advance.

Was it helpful?

Solution

You'll need to write some code.

The usually way of doing this is to put the logic into a transitional attribute in your entity. Then code a custom getter for the transitional attribute such that the value of the attribute can change as other data changes.

In this case, cost would be your transitional attribute and it would be calculated based on the value of persisted attributes number and buy.

With binding, any user changes to number and buy will automatically be reflected in the display value of cost.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top