Remove NSArrayControllers selectedObjects on creation
I have a NSArrayController which gets populated using Cocoa Bindings fr开发者_开发知识库om a CoreData NSMangedObject Model. When I check the contents of the controllers array the first model object is always present in selectedObjects.
This is a problem because I bind this ArrayController to a CollectionView and allow its items to be selectable by checking the 'Selectable' checkbox in Interface Builder. So when the CollectionView loads the first item can not be selected (causing an event to fire) as according to the array its already selected.
I have tried removing the selectedObjects in awakefromNib but its always empty as it seems that the Cocoa Binding is the last thing to happen somewhere after awakefromNib.
Maybe im going about this the wrong way but any ideas on this one would be much appreciated.
Try to disable 'Avoid empty selection' option of your ArrayController in IB.
精彩评论