views:

428

answers:

2

I have a core data app set up, and everything is working pretty well. But there is one little problem. When I insert a new object into my entity I have it go to my NSTableViewCell, where I can edit it to the text I want, but there's one little issue, I can edit the cell, but I can't deselect it to save it to core data, it's stuck in edit mode and the only way I can get out of it is by quitting the application, AND it doesn't save the new name I just gave it in my cell.

A: 

What method are you using to connect the table view to the core data store? Bindings? Data Source?

My guess is that you haven't implemented this at all. If you are just getting starting then I suggest implementing an NSTableViewDataSource instance.

http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html

sosborn
I don't think NSTableViewDataSource is required for Core Data when using an NSArrayController - especially when requirements are simple.
Tom Duckering
I'm using bindings
Matt S.
Tom, yeah, it is not required, but it is good to implement one at least once to give a better understanding of the interaction between the data store and the view.Having said that though, your link to the Rentzsch video is a good one and gets my vote.
sosborn
+4  A: 

This kind of functionality is covered in the Core Data tutorials provided by Apple. It will get you to make use of the NSArrayController which is a very helpful class for synchronising the view (NSTableView) and the model (Core Data).

I believe this is a great place to see how this works: http://rentzsch.com/links/adcCoreDataVideoTutorial

Hope that helps.

Tom Duckering
That's not the problem. It all works fine and dandy like sour candy, BUT I can't deselect a cell when I add a new object
Matt S.
If you can't deselect the cell then it is most certainly not working fine and dandy like sour candy.At this point it would be best to show us your code. If you have not written any custom code yet then describe in detail how the bindings of the controllers and table column are set up.
sosborn
There is no custom code (yet). Here's how the bindings are set up:NSArrayCtrler to managed obj contextTableColumn value to ArrayctrlertableviewCell value to arrayctrlerI followed this guide: http://cocoadevcentral.com/articles/000085.php
Matt S.
Take another look at the guide, you don't actually bind NSTableViewCell to anything.
sosborn
But I'm using it in place of an NSTextField
Matt S.
You bind the column not the cell. This will let the table take care of the edit view for you.
Marcus S. Zarra