简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM