views:

36

answers:

2

I'm pretty new to Core Data and managed to get the NSTableView to show my Core Data values. The entity that the table uses is Emotes that have the two properties, Emote (string) and Usage (integer 16)

When a user selects a item, it will allow a person to copy that emote to clipboard. In order to do that, I need to get the ManagedObject of the selected row and send the Emote value in the object to the clipboard. I got the clipboard part, but stuck on the part in retrieving the data of the selected row from the data source.

What is the easiest way in getting the value of the selected row?

+1  A: 

You don't have to worry about what rows are selected; the table view will tell you what rows to copy by sending you (the data source) a tableView:writeRowsWithIndexes:toPasteboard: message.

Whatever you do in your implementation of tableView:objectValueForTableColumn:row:, you'll implement that method pretty much the same way, except that instead of retrieving and returning a single column value, you'll write (or at least promise) all of them at once, in whatever formats make sense, to the pasteboard.

Peter Hosey
+1  A: 

What is the easiest way in getting the value of the selected row?

The easiest way is to query the NSArrayController for

- (NSArray *)selectedObjects
Martin Brugger
I created a IBOutlet for the NSArray Controller and it worked like a charm after I created a NSArray and got the object value.
chikorita157