How to build an app that runs on Mac OS 10.6 and supports the NSUserNotificationCenter?

Viewed 1350

I did a lot of research but I just couldn't find what I'm looking for: Currently, both the Deployment Target and Base SDK of my app is set to 10.8, and it runs perfectly. I can properly post Notifications to Mountain Lions new Notification Center!

To build an app that also runs under Mac OS 10.6, I've set the Deployment Target to 10.6 and built it (as recommended in this thread). Unfortunately, the app crashes on 10.6, and the crash report is detailing that the NSUserNotificationCenter couldn't be found (No OS version handling).

--

So what I surely have to do, is to check, whether the NSUserNotificationCenter class exists:

notificationCenterIsAvailable = (NSClassFromString(@"NSUserNotificationCenter")!=nil);

and operate based on this boolean flag.

But what about Code that can't be based on this flag, like:

  • the interface ..: <NSUserNotificationCenterDelegate> {
  • or the type of the reference to the Notification Center: NSUserNotificationCenter *center in the class' properties?

My first thought was to dynamically alter the class header at runtime, i.e., add the methods and properties to handle the Notificaion Center based on whether the class exists or not, but this seems like really complex ?!

1 Answers
Related