Block-style notifications not called for workspace notification center
Originator: | markd | ||
Number: | rdar://11827110 | Date Originated: | 7/8/2012 |
Status: | Open | Resolved: | |
Product: | Mac OS X | Product Version: | 10.7.4 11E53 |
Classification: | Serious Bug | Reproducible: | Always |
Summary: Notifications registered for NSWorkspace's notification center, using the block syntax do not fire. Notifications using the old-school syntax work fine, and if they exist, cause the block-syntax blocks to trigger as well. Steps to Reproduce: Register a notification handler with: center = [[NSWorkspace sharedWorkspace] notificationCenter]; [center addObserverForName: nil object: nil queue: nil usingBlock: ^(NSNotification *notification) { NSLog (@"+++++++ WORKSPACE??? %@ -> %@", notification.name, notification.userInfo); }]; Expected Results: A flurry of notifications Actual Results: nothing Regression: If I register a notification handler with the old-school syntax, it works great. In fact, the block-based version starts working. Notes: A sample project is attached. (OpenRadar folks - here's the function in question) - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSNotificationCenter *center; #if 0 center = [[NSWorkspace sharedWorkspace] notificationCenter]; [center addObserver: self selector: @selector(observeWorkspaceStuff:) name: nil object: nil]; #endif center = [[NSWorkspace sharedWorkspace] notificationCenter]; [center addObserverForName: nil object: nil queue: nil usingBlock: ^(NSNotification *notification) { NSLog (@"+++++++ WORKSPACE??? %@ -> %@", notification.name, notification.userInfo); }]; } Run it as-is, juggle between apps, no notifications show at all. Change the #if 0 to #if 1 and re-run, and juggle between apps. Now *both* notifications fire.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!