Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa 有没有办法检测SDK中支持的选项_Cocoa_Osx Mountain Lion - Fatal编程技术网

Cocoa 有没有办法检测SDK中支持的选项

Cocoa 有没有办法检测SDK中支持的选项,cocoa,osx-mountain-lion,Cocoa,Osx Mountain Lion,“使用基于SDK的开发”“说明如何使用弱链接的类、方法和函数 我用过这个 if ([NSByteCountFormatter class]) { ... } 是否有任何方法可以检测支持的选项,例如 NSRegularExpressionSearch The search string is treated as an ICU-compatible regular expression. If set, no other options can apply except NSCaseIn

使用基于SDK的开发”“说明如何使用弱链接的类、方法和函数

我用过这个

if ([NSByteCountFormatter class]) {
    ...
}
是否有任何方法可以检测支持的选项,例如

NSRegularExpressionSearch
The search string is treated as an ICU-compatible regular expression.
If set, no other options can apply except NSCaseInsensitiveSearch and NSAnchoredSearch.
You can use this option only with the rangeOfString:... methods and stringByReplacingOccurrencesOfString:withString:options:range:.

Available in OS X v10.7 and later.

要测试类(例如
NSUserNotificationCenter
)是否存在,请执行以下操作

if(NSClassFromString(@"NSUserNotificationCenter"))
{
    //...
}
BOOL NSWindowDidChangeBackingPropertiesNotificationIsAvailable = (&NSWindowDidChangeBackingPropertiesNotification != NULL);
if (NSWindowDidChangeBackingPropertiesNotificationIsAvailable) 
{
    //...
}
要测试常量(例如NSWindowDidChangeBackingPropertiesNotification)是否存在,请执行以下操作

if(NSClassFromString(@"NSUserNotificationCenter"))
{
    //...
}
BOOL NSWindowDidChangeBackingPropertiesNotificationIsAvailable = (&NSWindowDidChangeBackingPropertiesNotification != NULL);
if (NSWindowDidChangeBackingPropertiesNotificationIsAvailable) 
{
    //...
}
也请查看此答案:

在你的情况下,这看起来像

BOOL NSRegularExpressionSearchIsAvailable = (&NSRegularExpressionSearch != NULL);
if (NSRegularExpressionSearchIsAvailable)
{
    //...
}

这可能适用于定义为APPKIT_EXTERN NSString*常量NSWindowDidExitVersionBrowserNotification的NSWindowDidChangebackingProperties通知,因此您可以获取其地址。NSRegularExpressionSearch在NSString.h中定义为NSRegularExpressionSearch NS_ENUM_AVAILABLE(10_7,3_2)=1024,因此您无法获取其地址,并将在编译时转换。