Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS X App backwards compatibility 10.6 and 10.7 while using NSPopovers

What is the best way to implement backwards compatibility, when building an app for Mac OS X 10.7 but also staying compatible for 10.6?

I have an application that uses an NSPopover when the client is 10.7 and an NSMenu when the client is 10.6. The problem is, that when starting the app on a 10.6 machine, the app crashes with a "symbol not found" exception, saying that (kind of) "_OBJC$_NSPopover could not be found in AppKit". Do i have to use id throughout the application for the new features?

like image 357
ovm Avatar asked Aug 04 '11 12:08

ovm


1 Answers

You can get the class object for NSPopover by using the function NSClassFromString() this return a Class object with you can use to create instances for example

id  thePopover = [[NSClassFromString(@"NSPopover") alloc] init];

another possibility is to have two separate nib files one for 10.6 and one for 10.7, the nib does not have to be the complete interface, just the part that contains the NSPopover and then load the appropriate nib file at run time.

like image 184
Nathan Day Avatar answered Oct 02 '22 07:10

Nathan Day