Re: RE: RE: Events between Objective C objects
Re: RE: RE: Events between Objective C objects
- Subject: Re: RE: RE: Events between Objective C objects
- From: Rolf <email@hidden>
- Date: Tue, 20 May 2003 00:14:49 +0200
I have tried using NSNotification now. It's working nicely, and seems to be exactly what I'm looking for. I was under the impression that Notifications were broadcast and thus had a performance penalty, but as you point out objects register for the notifications they are interested in = exactly
what I need. Thanks! The next challenging thing I need to do is to use this over the Java bridge (ie Objective C NSNotification <-> Java EventObject/EventListener). That will probably be a tough one, but then what's life without challenges :-)
/Rolf
20.05.2003 00:07:50, skrev "Jonathan E. Jackel" <email@hidden>:
>
> 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.