iOS4上的iOS5课程

use*_*320 1 objective-c backwards-compatibility ios4 ios ios5

我想在iOS 5中使用一些也在iOS 4上运行的应用程序.我了解如何使用respondsToSelector:有选择地在较新的OS版本上调用新方法.在运行时确定类是否存在的等价物是什么.

hyp*_*ypt 5

if (NSClassFromString(@"ClassName") != nil)
{
    // use class
}
else
{
    // not available, deal with it.
}
Run Code Online (Sandbox Code Playgroud)