Is there a way to provide an implementation of a method (which has the same method name defined by the framework) only when the method is not yet defined in the system? For example, the [NSSomeClass someMethod:] method exists only in Mac OS X 10.6, and if my application runs in 10.5, I will provide this method definition in the category. But when the application runs in 10.6, I want the method supported by the OS to be executed.
Background: I am creating an application designed for 10.5 and 10.6. The problem is that I recently realized that the +[NSSortDescriptor sortDescriptorWithKey:ascending:] method only exists in 10.6, and my code is already inundated with this method call. I could provide a default implementation for it (since this time it is not too difficult to implement it myself), but I want the native to be called whenever my application runs on 10.6. In addition, if I encounter similar problems in the future (with more complicated methods to implement), I may not be able to get away with providing a single-layer replacement.
This question is vaguely similar to Overriding a method through the ObjC Category and calling the default implementation? , but the difference is that I want to provide implementations only when the system does not work, t already exists.
Thanks.
objective-c cocoa macos
adib
source share