• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSWorkspace's notificationCenter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSWorkspace's notificationCenter
      • From: j o a r <email@hidden>
    • Re: NSWorkspace's notificationCenter
      • From: Dan Saul <email@hidden>
  • Prev by Date: Re: Why would I not be able to load the NIB file?
  • Next by Date: Re: Odd NSData initWithContentsOfURL: issue
  • Previous by thread: Re: Training in Australia?
  • Next by thread: Re: NSWorkspace's notificationCenter
  • Index(es):
    • Date
    • Thread