检查可用性似乎工作正常,但我似乎无法设置NSURLIsExcludedFromBackupKey密钥而不会在启动时出现此崩溃:
dyld:未找到符号:_NSURLIsExcludedFromBackupKey引用自:/ Users/sam/Library/Application Support/iPhone Simulator/5.0/Applications/B0872A19-3230-481C-B5CE-D4BDE264FBDF/Transit.app/Transit预期:/ Applications/Xcode. app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Foundation in/Users/sam/Library/Application Support/iPhone Simulator/5.0/Applications /B0872A19-3230-481C-B5CE-D4BDE264FBDF/Transit.app/Transit
这是我的方法:
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL {
if (&NSURLIsExcludedFromBackupKey == nil)
return NO;
NSError *error;
[URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];
return (error != nil);
}
Run Code Online (Sandbox Code Playgroud)
如果我注释掉这一行,崩溃就会消失:
[URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];
Run Code Online (Sandbox Code Playgroud)
我必须弱化基金会吗?
编辑:不确定它是否有所作为,但这种方法被放在一个NSFileManager类别中.