Search code examples
objective-ccocoansarraycocoa-bindingsnsarraycontroller

Bind value to nth object of array


I have an NSView and an NSArrayController and I'd like to bind some values inside that view to an object in the array controller's arrangedObjects array. How would I do this? I thought about creating a property like "currentObject" and bind everything to that. But this seems ugly to me..

(I only have one view for all the objects but the user should be able to click on next and backward.)


Solution

  • What are you really trying to accomplish? Normally a "detail view" is bound to the array controller's selection, not an object at a given index. If you'll always be wired to the same object, just use an NSObjectController, set its content object to the desired one and bind your view to it instead.