Re: NSNotification vs message callback?
Re: NSNotification vs message callback?
- Subject: Re: NSNotification vs message callback?
- From: "l.m.orchard" <email@hidden>
- Date: Tue, 7 Aug 2001 10:55:06 -0400
On Tuesday, August 7, 2001, at 01:17 AM, Lloyd Sargent
<email@hidden> wrote:
>
Personally, I think what you are doing is the safest. NSConnections
>
allow you the ability to do some really cool things that you can't with
>
NSNotification. (Like if you set up something that is a server and later
>
decide "hey, maybe multiple people want to be able to look at this
>
junk"). Cool stuff.
>
>
However, the BIGGIE is that NSNotification is not really thread safe per
>
se. Which is, of course, TERRIBLY annoying, but there ya go.
Well, just to clarify.. Right now I'm using an NSConnection which
communicates directly to a supplied object via a supplied selector. If I
started using NSNotifications, I'd be using that same NSConnection, only
now I'd be sending messages back to self in the main thread, which would
then send out NSNotifications on the main thread.
So, everything still happens on the main thread, with the difference being
that in the first case, messages are delivered directly, but in the second
case, messages are broadcast out via NSNotifications.
>
Personally, I'm of the background that if you can't see a good reason to
>
put it in the first cut of code, why burden yourself (and whoever
>
maintains it) with stuff you don't need?
Well, it works... but I'm just learning ObjC and Cocoa, so I'm trying to
wrap my head around the idiom and get some good practices down early.
--
Leslie Michael Orchard <email@hidden>
ICQ: 492905 (home) 11082089 (work)
"...see you space cowboy..."