iOS plist 无法从 plist 加载数据,但可以在模拟器上运行

标签 ios xml load plist tableview

-(NSString*)dataFilePath{        
    NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentDirectory = [path objectAtIndex:0];

    return [documentDirectory stringByAppendingPathComponent:@"ProperyList.plist"];
}

iDevice 无法从此路径加载数据,只有模拟器可以。

最佳答案

首先,NSLog 从此方法返回的 dataFilePath 值,然后检查您的文档目录中是否存在 plist 文件 (PropertyList.plist)。使用以下代码来检查这一点:

NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL success = [fileManager fileExistsAtPath:dataFilePath];

您还必须确认您是否使用了正确的文件名。 iOS 设备区分大小写,而模拟器则不区分大小写。

关于iOS plist 无法从 plist 加载数据,但可以在模拟器上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11138193/

相关文章:

performance - jmeter延迟与实际浏览器负载测试

javascript - 在加载时应用选择背景颜色?

node.js - NodeJS 负载/压力测试结果

python - 在 Python 中复制和写入 XML 节点

ios - 从 mapView.annotations 访问 MKAnnotationView

ios - 是否可以忽略 iOS 中的一种推送通知

ios - 自定义 UICollectionViewCell 中的 UIActivityIndi​​cator - 仅在第一个单元格中显示/设置动画

java - 针对 XSD 的 xml 验证 : Invalid content was found starting with element xxx

c# - 将 XML 反序列化为对象数组或单个对象

ios - 使用 saveToURL :forSaveOperation:completionHandler: 自动删除 UIManagedDocument 文件