Re: IB: new user question
Re: IB: new user question
- Subject: Re: IB: new user question
- From: James Spencer <email@hidden>
- Date: Sat, 27 Dec 2003 11:57:30 -0600
On Dec 27, 2003, at 10:27 AM, T Reaves wrote:
> Hello all. I'm learning Mac development, and I have a basic question
> about IB.
>
> I have a UI with a table and an outline. I also have a couple data
> sources for them, and an app controller in the Instances panel in the
> nib file. I control-drag a connection from an object - he table for
> example - to the controller. In the inspector the Target/Action panel
> shows what actions are available in the controller class. Cool so
> far. My question is, what decides what event triggers the action?
>
> Looking at the docs, there are several notification events. So does
> any one of those events trigger the method in the receiver being
> called?
>
This is a Cocoa question and you will do better asking in the Cocoa
list but the short answer to your question is that the action message
is sent to the target by NSControl's - (BOOL)sendAction:(SEL)theAction
to:(id)theTarget. This method is primarily invoked by the
trackMouse:inRect:ofView:untilMouseUp: method.
No, notifications don't have anything to do with the target/action
process. As a general matter, as discussed above, the target/action
process relates to mouse clicks and as such, you probably don't need to
set a target and an action for your table view (particularly if you
don't know what you want to do with the action.) They are mostly used
in connection with buttons etc but in fact can be used with any class
that is a subclass of NSResponder. (Note that with table views, the
one action type thing you do sometimes want to override is what to do
with a double click and there is a specific method to change the double
click action).
I can't go through how all this works here and you really need to get a
good book on the subject but notifications are posted when certain
events occur and any receiver can register to receive those
notifications. Related to this process are delegate methods and it is
those delegate methods that you will use most of the time to populate
your table view, save changes made in the table view, and alter the
views behavior. To use these methods, you simply write them into a
class which you then specify in IB as your delegate. The table view
will call any implemented delegate methods as appropriate. Delegate
methods are essentially methods that respond to notifications for which
they are automatically registered without you having to do it
explicitly.
Spence
James P. Spencer
Rochester, MN
email@hidden
"Badges?? We don't need no stinkin badges!"
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.