Compatible with Mac OS X App 10.6 and 10.7 when using NSPopovers

What is the best way to implement backward compatibility when creating an application for Mac OS X 10.7, and also stay compatible for 10.6?

I have an application that uses NSPopover when the client is 10.7 and NSMenu when the client is 10.6. The problem is that when the application starts on machine 10.6, the application crashes with the exception "character not found", saying that (type) "_OBJC $ _NSPopover cannot be found in AppKit". Do I need to use id throughout the application for new features?

+6
source share
1 answer

You can get a class object for NSPopover using the NSClassFromString () function, this returns a class object that 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, nib does not have to be a complete interface, just the part that contains NSPopover, and then loads the corresponding nib file at runtime.

+2
source

Source: https://habr.com/ru/post/894277/


All Articles