使用NSURLIsExcludedFromBackupKey而不会在iOS 5.0上崩溃 [英] Use NSURLIsExcludedFromBackupKey without crashing on iOS 5.0

查看:121
本文介绍了使用NSURLIsExcludedFromBackupKey而不会在iOS 5.0上崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检查可用性似乎工作正常,但我似乎无法设置 NSURLIsExcludedFromBackupKey 键而不会在启动时出现此崩溃:

The check for availability seems to be working fine but I can't seem to set the NSURLIsExcludedFromBackupKey key without getting this crash on launch:


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

dyld: Symbol not found: _NSURLIsExcludedFromBackupKey Referenced from: /Users/sam/Library/Application Support/iPhone Simulator/5.0/Applications/B0872A19-3230-481C-B5CE-D4BDE264FBDF/Transit.app/Transit Expected in: /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);
}

如果我注释掉这一行,崩溃就会消失:

Crash goes away if I comment out this line:

[URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];

我必须弱化基金会吗?

编辑:不确定它是否有所作为,但此方法放在 NSFileManager 类别中。

not sure if it makes a difference, but this method is put inside an NSFileManager category.

推荐答案

这似乎是iPhone 5.0模拟器的一个错误。我尝试在5.0设备上运行代码,没有崩溃。将此错误报告为 rdar:// 11017158

This seems to be a bug with the iPhone 5.0 Simulator. I tried running the code on a 5.0 device and no crash. Reported this bug as rdar://11017158.

编辑:这已在Xcode 4.5 DP2中修复(不确定是否在4.4中)。

EDIT: this has been fixed in Xcode 4.5 DP2 (not sure if it is in 4.4).

这篇关于使用NSURLIsExcludedFromBackupKey而不会在iOS 5.0上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆