开发者

Remove NSArrayControllers selectedObjects on creation

开发者 https://www.devze.com 2023-03-24 22:28 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消