Re: Events between Objective C objects
Re: Events between Objective C objects
- Subject: Re: Events between Objective C objects
- From: publiclook <email@hidden>
- Date: Mon, 19 May 2003 18:01:35 -0400
Use -setTarget: and -setAction: to set the receiver of a message and
the selector for the message.
On Monday, May 19, 2003, at 05:20 PM, Rolf wrote:
Hi,
Thanks for your help :-)
Jonathan:
I'm sure its pretty basic stuff, but I was not referring to just
messaging (although messaging would be involved at a lower level of
course) ..
Here's an example from Delphi (that I have more experience with) which
illustrates what I'm searching for in Objective C:
object1.OnSomeConditionOccured := object2.theConditionHasOccured.
After this line of code has been run, object1 will, (asynchronously -
when the condition occurs), call instance method
theConditionHasOccured of object2. The two classes of object2 and
object1 do not need to anything about each other, just the definition
of the event object. The event
object can be customised and contain any number and mix of parameters.
To close the "connection" one would issue:
object1.OnSomeConditionOccured := nil;
Clark: I will look into NSNotifications. I was assuming that there
would be some performance penalty in using broadcasting instead of a
one-to-one type connection. But if that isn't the case then I guess
NSNotifications will do.
/Rolf
19.05.2003 23:00:36, skrev "Jonathan E. Jackel" <email@hidden>:
I think you are referring to messaging. Objects send messages to
each other
all the time. A foo instance can send a message like [bar
doSomething]; it
only needs bar to point to an object that responds to a doSomething
message
(actually, if bar doesn't respond to doSomething, it just ignores the
message with no harm done).
Outlets in nibs are just freeze-dried pointers to objects. When the
nib's
controller says "if ([button state] == NSOnState)", it's sending a
message
to button, which is a pointer to a button object. The assignment of
the
pointer is done by the nib instead of in code, using the connections
you set
up in Interface Builder.
Read up on Objective C. This is real basic stuff. The docs are
probably on
your hard drive.
Jonathan
-----Original Message-----
From: email@hidden
[mailto:email@hidden]On Behalf Of Rolf
Sent: Monday, May 19, 2003 3:55 PM
To: email@hidden
Subject: Events between Objective C objects
Hi,
I'm searching for a simple straight forward way of implementing
events between non-visual objects coded in Objective C. The event
mechanism must be synchronous, should not involve broadcasting
and does not need to support multiple listeners - one to one
connections is ok. Registering
for event reception (making a "connection" in Objective C
terminology?) and triggering of the event must be done
programatically - i.e no InterfaceBuilder. How's this done in
Objective C ?
When making connections in InterfaceBuilder I see that
IBAction/IBOutlet are used but I don't see the actual code that
registers for event and that generates the event. How is this
done programatically ?
/Rolf
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.