views:

162

answers:

1

Hi all, I'm trying to write a simple stock check program, and I have a Table View binded to Core Data. The table has 3 columns: Model, Price and Quantity In Stock.

I have a NSTextField and a NSButton underneath this, so that the user can enter the quantity they wish to buy, and when they click "add to cart", the program should fetch the value in the "quantity in stock" column, in the selected row, and deduct the value entered into the NSTextField, obviously, it would return an error is there isn't enough in stock. At the same time, the whole row, model, price and quantity desired should be added to an "invoice".

My question is this: How would I go about retrieving the value in the quantity field at the selected row, manipulating it, and reinserting it into the table?

Or would I have to edit the Core Data directly? And how would I go about that?

Many thanks, Michael

+3  A: 

I assume the table is, in fact, bound to an NSArrayController instance. The controller's selectedObjects property is what you want.

Barry Wark
Thanks for your reply. It is bound to an NSArrayController, but I didn't set up the core data with code, just the datamodel and ctrl+dragging.How would I go about setting up and using the "selectedObjects" property?Thanks!
Michael