查看文档:https://developer.apple.com/library/mac/文档/可可/引用/基金/类/NSData_Class/引用/Reference.html
我看到NSDataWritingFileProtectionComplete是"在OS X v10.8及更高版本中可用",但当我试图在我的代码中使用它时,我有一个编译错误。检查NSData头,我发现这个功能只在iOS中可用:
NSDataWritingFileProtectionComplete NS_ENUM_AVAILABLE_IOS(4_0)
我做错了什么或文档是不正确的?
查看MacOS 10.8 SDK中定义的枚举,我看到:
typedef NS_OPTIONS(NSUInteger, NSDataWritingOptions) {
NSDataWritingAtomic = 1UL << 0, // Hint to use auxiliary file when saving; equivalent to atomically:YES
NSDataWritingWithoutOverwriting NS_ENUM_AVAILABLE(10_8, 6_0) = 1UL << 1, // Hint to return prevent overwriting an existing file. Cannot be combined with NSDataWritingAtomic.
NSDataWritingFileProtectionNone NS_ENUM_AVAILABLE_IOS(4_0) = 0x10000000,
NSDataWritingFileProtectionComplete NS_ENUM_AVAILABLE_IOS(4_0) = 0x20000000,
" NS_ENUM_AVAILABLE_IOS
"是一个展开为
#define NS_ENUM_AVAILABLE_IOS(_ios) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_##_ios)
"__MAC_NA
"位表示"不适用",这意味着文档当前是错误的。此功能仅在iOS中可用。