NSWorkspace's notificationCenter
NSWorkspace's notificationCenter
- Subject: NSWorkspace's notificationCenter
- From: Joannou Ng <email@hidden>
- Date: Mon, 14 Mar 2005 00:59:58 -0500
Hi folks,
Imagine a simple app with two buttons: Add & Remove
Add does the following:
- (IBAction)add:(id)sender {
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
selector:@selector(deviceMounted:)
name:@"NSWorkspaceDidMountNotification" object:[NSWorkspace
sharedWorkspace]];
}
Remove does the following:
- (IBAction)remove:(id)sender {
[[[NSWorkspace sharedWorkspace] notificationCenter]
removeObserver:self name:@"NSWorkspaceDidMountNotification"
object:[NSWorkspace sharedWorkspace]];
}
Then, we have the observer method:
- (void)deviceMounted:(NSNotification *)notification {
NSLog(@"Great!");
}
Here's the issue:
I click Add.
I trigger the notification by mounting something.
The observer method gets invoked.
Great!
I click Remove.
I trigger the notification by mounting something again.
The observer method does not get invoked.
Great!
I click Add.
I trigger the notification by mounting something again.
The observer method gets invoked TWICE!
The invocations will increase as I repeat...
Any ideas?
Cheers, Joannou.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden