开发者

IKImageBrowserView appears to not bind properly

开发者 https://www.devze.com 2023-01-07 20:19 出处:网络
my question relates to Interface Builder and an IKImageBrowserView not implementing bindings as I would expect.

my question relates to Interface Builder and an IKImageBrowserView not implementing bindings as I would expect.

I have a fairly long key path to get to an NSArrayController, the contents of which I want to display in the IKImageBrowserView.

This is the key path I am binding an NSTextField's Display Pattern binding to: currentOrder.imagesArray.unvalidatedImages.arrangedObjects.@count of the AppDelegate. This works fine and gives me the number of unvalidated items in the array of images belonging to the current order, which is what it is supposed to.

When I attempt to bind the following key path to the IKImageBrowserView's content: currentOrder.imagesArray.unvalidatedImages.arrangedObjects of the AppDelegate, Interface Builder gives no error but instead acts as if I hadn't entered anything. When I click back to the inspector, the bindings key path is blank again.

It does however log the following to the Console: Ignoring exception related to working with bindings: NSUnknownKeyException, [<NSCustomObject> addObserver:<IKImageBrowserView ...> forKeyPath:@"currentOrder.imagesArray.unvalidatedIm开发者_Go百科ages.arrangedObjects" ...] was sent to an object that is not KVC-compliant for the "currentOrder" property.

My AppDelegate implements currentOrder as an @property retained and all sub-keys are also @properties. I can be sure that these properties are KVC-okay because the NSTextField above is able to read changes without a problem. Interestingly enough the IKImageBrowserView's selectionIndexes is able to bind to ...unvalidatedImages.selectionIndexes, it's only the content that can't.

I have implemented a workaround whereby I have placed an NSArrayController in my nib file and bound the Content Array to ...arrangedObjects then bound the IKImageBrowserView to the array controller but would be very happy to have a neater solution, or at least to know whether I am doing anything wrong.

Thank you!


Did you try implementing the methods of <IKImageBrowserDataSource> in your app delegate, and using the _dataSource connection instead of a binding? That works for me, and is how the Apple tutorial has you do it.

You basically only need to implement – numberOfItemsInImageBrowser: and – imageBrowser:itemAtIndex: to provide the data, which isn't too bad. The slightly trickier part is to implement an <IKImageBrowserItem> class to wrap your data, but even that doesn't require massive effort. The tutorial linked above should help a lot.

0

精彩评论

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