0

I have a question regarding the cocoa binding.

I have a xib file, inside this xib file (named AddInformation.xib), I have added a array controller. I have bound the array to one of my NSMutableArray.

I have also set an IBOutlet for this array controller so that I can manipulate the selection of the array controller

@property (weak) IBOutlet NSArrayController *arrayController;

so, somethere in the code, when I called:

myViewController = [[NSViewController alloc] initWithNibName:@"AddInformation" bundle:nil];

BOOL b = [arrayController setSelectionIndex: 2]; // b is returned as NO

it doesn't work, it always return the first object in the array, even thought I changed the selectionindex to 2 (I have more than 10 objects in the array)

am I missing something?

GoZoner
  • 67,920
  • 20
  • 95
  • 145
Josh
  • 692
  • 2
  • 9
  • 38
  • What always return the first object in the array? How are you accessing it? – Ken Aspeslagh Apr 02 '13 at 22:46
  • "it always return the first object in the array" - can you add the code that relates to your statement to the question? – Jay Apr 03 '13 at 06:05
  • here is an example.in the xib I have a name field. So to bind it, I binded it to the array controller (selected it from the drop down), in the controller key I set it to "selection", then bind to the name field. – Josh Apr 03 '13 at 13:21
  • Sounds like you might be calling setSelectionIndex: before you array controller has populated its values. Have you tried something like: `[arrayController fetchWithRequest:nil merge:NO error:&error];` then try to set your selectionIndex? – macandyp Apr 03 '13 at 14:50

0 Answers0