views:

47

answers:

1

I cannot find documents about the way, in which Interface Builder determines the Sent Message outlets for the graphical connections between components triggering events and messages of other components.
I want to generate components encapsulating Finite State Automata. The input part is simple, just define IBAction messages and you can connect them in in Interface Builder. The tricky part is obviously the other end of such connections.
I want to provide for each event triggered by the FSM a distinct outlet, like the 'selector' outlet of a NSButton (listed under 'Sent Messages' on the 'Connections' tab of the inspector).
How do I specify such interfaces programmatically and can I specify more than one of these? Or is this approach not suitable; would Notifications be a better way? (I am used graphical connections from Visual Age and Parts, so I would prefer them, but in Interface Builder, the support for such connections seems somehow limited).

Thanks in advance

The first part of my question has been ansered in the question 'Send An Action Cocoa - IBAction'. I am still looking for a possibility to define more than one 'Sent Message'.

+1  A: 

When you implement your method using IBActions, the object that generated the message (the sender) is passed to the message. So if I have a button on my interface that says "Logout" and an action on some controller object named logout: and I have wired these up, the method receives the instance of the button that triggered it. For example:

- (void)logout:(id)sender
{
  // sender is the instance of whichever wired button triggered
  // this action. We just NSLog() it for now.
  NSLog(@"-[%@ logout:%@]", self, sender);
}

Other objects may call this action as well, and may pass themselves as the sender or may pass nil. The details of this would be left up to you as the designer.

Jason Coco
That is clear, but the question is, how I have to design the sender, so that it is recognized as sender by Interface Builder and that IB can establish the connection. For the receiver, it is clear, that defining the method as IBAction and using one parameter is sufficient. I am trying to find out, how I have to design the senders interface to support the connection mechanism of IB.
Stefan Sachs