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:
..: <NSUserNotificationCenterDelegate> {
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 ?!
Those are compilation issues and will be fine all the time the Base SDK is 10.8. The center
pointer can remain at nil
if NSUserNotificationCenter
does not exist, and you could therefore use that as a flag to check if you are doing notifications or not in code run after the test.
EDIT In fact leaving it nil
will mean you don't even need to check for it; just send messages as normal and they will be ignored if the pointer is nil
(this is unless the creation of the message is expensive and you want to save some CPU cycles).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With