问题
Look at this great screenshot and I think you can imagine what I could ask...
screenshot http://a4.s3.p.quickshareit.com/files/screenshot_75d0fc54a05ec7eae3f410.png The players:
to the right: the preferences-panel and a
NSTableView
to the left: main-window with aNSPopUpButton
(under theNSMenu
;] )
The selected object of the popup is binded to one of these in the tableview. This ugly thing (what you can see there) appears when I remove the (in the popup selected) object from the tableview. I'm using CoreData and the NSArrayController is binded to one Entity.
I found 2 interesting things:
NSManagedObjectContextObjectsDidChangeNotification
[NSPopUpButton synchronizeTitleAndSelectedItem];
With the first I know when someone removes a item from the tableview; the second doesn't work unfortunately for my problem...
So any idea how to blast away this ugly thing? =D
By the way: If you are interested in this nice app and a native URL shortener you should look here.
回答1:
If I understand your description of how everything is built up correctly, selectedObject in your NSPopupButton is bound to some value in your NSTableView. My guess is that you are using dataSource methods to provide the table with data, and bindings to match the data in the popup with the table.
You should probably use an NSArrayController for the actual dataset, bind its content array to an NSMutablearray in your controller, and bind both the tableView and the NSPopupButton to the arrayController, instead of binding one control to the other. The problem you describe does not seem to have very much to do with NSManagedObject, except for seeing a default implementation of -description in this situation, but moreso with using bindings in an unconventional way.
回答2:
I have it!
I just unbinded the selected object of the NSPopUpButton and binded it again. It performs this action only
when the selected object was removed from list. ;)
来源:https://stackoverflow.com/questions/543283/remove-correctly-selected-nsmanagedobjects