RE: RE: Events between Objective C objects
RE: RE: Events between Objective C objects
- Subject: RE: RE: Events between Objective C objects
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Mon, 19 May 2003 18:07:50 -0400
>
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.
Now it sounds like you want notifications. I must have misunderstood your
first message.
Notifications are not broadcast. Objects register for the notifications
they are interested in. When those notifications come in to the
notification center, they are forwarded to the objects that registered. The
penalty is simply one extra message sent to the notification center.
Try it. See if it works well enough. If it's not good enough, optimize
later.
Jonathan
_______________________________________________
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.