> > Which means that the second one (if it should come at all) will be  
> > discarded.
>
> No it doesn't. The notification observer method removes *one*  
> notification observer. The other observer remains until the method is  
> called the second time.

I'm not sure I understand you. I guess that you mean that in the end
two notifications might be delivered. This is however never the case -
for several reasons, the most important one here being that the first
call to [[NSDistributedNotificationCenter defaultCenter]
removeObserver:self name:GROWL_IS_READY object:nil]; removes the
singleton GrowlApplicationBridge from the center, so no more
notifications are delivered to it.

> >> If -growlIsReady is not safe to call twice (and we can't assume  
> >> that it is), then this can result in unpredictable problems.
>
> > But we can check and don't need to assume, right?
>
> Err, no. There is no way to know whether a method is safe to call twice.

I'm not sure what you want to say. We also have no way to proove that
there are no unicorns. Still I bet that you are sure enough about this
fact that you will happily deliver somebody to a mental institute if
he insists on having seen one.

> > * Calling setGrowlDelegate: needs to be safe to call multiple times  
> > anyway because it's clients might
>
> Right. The problem is calling it multiple times without running the  
> run loop. Like this:
>
>         [GAB setGrowlDelegate:foo];
>         [GAB setGrowlDelegate:bar];

And this might also happen, because of programmer error So it still
needs to be either safe, or it should raise an exception.

It is safe however, so no exception required.

> > * Calling setGrowlDelegate: multiple times is safe - because the  
> > critical behaviour - talking to the daemon[ -] happens via  
> > DistributedNotifications - where this behaviour is specified and  
> > safe as documented.
>
> GAB's message to GHA is in the form of launching it with  
> a .growlRegDict file. Only GHA's response comes in the form of a DNC  
> notification.
>
> Launching multiple files is safe, as is launching the same file  
> multiple times. I'm not sure about distributed notifications, however.

That is great! Because I can add to this the knowledge that
distributed notifications are safe (in this context) too.

> > I'm asking this because I like about this solution that it is very
> > simple - and it also gives a preset from which refactoring can pursue.

With that on the table, what about the bug now?

> I have much more ambitious plans for a new API in my head (which we  
> will not implement for quite some time because we have more immediate  
> things to tackle). I may write them down during my flight tomorrow.

I'd love to hear those!

cu Martin

p.s.: If you'd like to have a look at distributed notifications and
how they work, have a look here and play with this:

-- receiver.m --
#import <Foundation/Foundation.h>

@interface Receiver : NSObject @end
@implementation Receiver
- (void) receiver:(NSNotification *)aNotification
{
        NSLog(@"I see them!");
}
@end


int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

        id receiver = [Receiver new];
        [[NSDistributedNotificationCenter defaultCenter] addObserver:receiver
selector:@selector(receiver:) name:@"fnord" object:nil];
        [[NSDistributedNotificationCenter defaultCenter] addObserver:receiver
selector:@selector(receiver:) name:@"fnord" object:nil];
        [[NSDistributedNotificationCenter defaultCenter]
removeObserver:receiver name:nil object:nil];

        [[NSRunLoop currentRunLoop] run];
        [pool drain];
    return 0;
}

-- sender.m --
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

        [[NSDistributedNotificationCenter defaultCenter]
postNotificationName:@"fnord" object:nil];

        [pool drain];
    return 0;
}

-- done --
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Growl Discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/growldiscuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to