-1

I know this is an easy one, but I just thought I could spare myself some (more) time searching through the documentation.

Usually, when I have an "Add" and a "Remove" button, along with an NSArrayController, I simply have to click-drag from each button and connect them to the add: and remove: actions of the NSArrayController.

Now, I'm trying to do the very same thing, programmatically with NSArrayController (co) :

[addButton setAction:@selector(add:)];
[addButton setTarget:co];

What am I doing wrong?


The rest of the NSArrayController operations, handling an NSMutableArray of dictionaries, etc works fine.

Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
  • 2
    Well, what's going wrong? The code you posted is correct, so you're going to need to help us help you diagnose the problem by giving more info... – Itai Ferber Apr 03 '12 at 14:48

1 Answers1

1

My psychic debugger* tells me that you're probably doing this in an init method, where neither of the outlets, to the array controller or the button, are connected yet.

Put this into awakeFromNib or a method which you know is called after the xib is loaded.


*psydb, of course.

jscs
  • 63,694
  • 13
  • 151
  • 195
  • Hmmm... Unfortunately, everything is connected and nope,it's not the `init` method either... – Dr.Kameleon Apr 03 '12 at 16:21
  • You're sure that `co` and `addButton:` are not `nil` at this point? Then please do as Itai asked and add more information -- what is actually happening? – jscs Apr 03 '12 at 16:23