iOS开发笔记:大小写敏感的iOS文件系统,而iOS模拟器竟然对大小写不敏感
2012-03-03 15:22
519 查看
一个程序在模拟器上运行正常,但在真机上运行就是出错,排除了下列多种可能性:
(1)用5.0的SDK开发,部署在4.3的真机系统上
(2)越狱的iPhone机器
(3)文件的汉字编码不正确
(4)ZIP文件包解压到iPhone机器里有问题
(5)苹果开发证书安装不正确
最后发现是该死的iOS文件系统竟然对大小写敏感!!!静下心来想想也是,MAC等系统都是从UNIX系统修改过来的,大小写早应该小心。从网上查了一下,在这篇文章里有清楚的描述,原话是这样的:
另外得到的一个小经验就是要对NSError的错误信息进行检查。
NSError *error = nil;
NSString *str = [[NSString alloc] initWithContentsOfFile:path encoding:enc error:&error];
要检查一下error对象,或者检查一下str对象,尽早发现错误。
(1)用5.0的SDK开发,部署在4.3的真机系统上
(2)越狱的iPhone机器
(3)文件的汉字编码不正确
(4)ZIP文件包解压到iPhone机器里有问题
(5)苹果开发证书安装不正确
最后发现是该死的iOS文件系统竟然对大小写敏感!!!静下心来想想也是,MAC等系统都是从UNIX系统修改过来的,大小写早应该小心。从网上查了一下,在这篇文章里有清楚的描述,原话是这样的:
Case Sensitivity It’s important to understand that the iOS file system is case sensitive. This means that your file and directory names must match exactly – README.txt and readme.txt would be considered different filenames.
This could be confusing for .NET developers who are more familiar with the Windows file system, which is case insensitive– “Files”, “FILES”, and “files” would all refer to the same directory.
So, although iOS devices are case sensitive and your code should be written with that in mind, the iOS Simulator is NOT case sensitive by default. This means if your filename casing differs between the file itself and the references to it in code, your code might still work in the simulator but that it would fail on a real device. This is one of the reasons why it’s important to deploy to an actual device early and often during iOS development.
大意就是iOS的文件系统是大小写敏感的,而在iOS模拟器里不敏感!从.NET过来的程序员们经常忽略这个问题(我就是这样),这也是要经常地、尽早地进行真机调试的一个主要原因。This could be confusing for .NET developers who are more familiar with the Windows file system, which is case insensitive– “Files”, “FILES”, and “files” would all refer to the same directory.
So, although iOS devices are case sensitive and your code should be written with that in mind, the iOS Simulator is NOT case sensitive by default. This means if your filename casing differs between the file itself and the references to it in code, your code might still work in the simulator but that it would fail on a real device. This is one of the reasons why it’s important to deploy to an actual device early and often during iOS development.
另外得到的一个小经验就是要对NSError的错误信息进行检查。
NSError *error = nil;
NSString *str = [[NSString alloc] initWithContentsOfFile:path encoding:enc error:&error];
要检查一下error对象,或者检查一下str对象,尽早发现错误。
相关文章推荐
- iOS 真机文件系统区分大小写,而模拟器可能不区分
- iOS开发笔记之三十一——日历NSCaledar使用过程中遇到的一个苹果系统bug
- ios开发笔记-5-配置文件
- ios有文件管理系统吗?自己开发的应用能不能像Android一样读取本地文件列表?
- IOS开发笔记(七)---对iOS多视图开发的补充(针对XCode4.2开发环境,Empty Application没有XIB/Storyboard文件的问题)
- IOS开发之文件系统NSFileManager
- IOS开发笔记之十四——使用系统相册或相机导致状态栏隐藏的问题(bug总结四)
- IOS开发 沙盒中的文件操作和文件系统NSFilemanager的操作
- iOS开发笔记-图标和图片大小官方最新标准
- iOS开发之数据存取( 显示Mac隐藏文件的命令 应用沙河 模拟器根路径 plist等)
- 《iOS开发笔记--系统通讯录的访问与添加联系人》
- 安装 Mac OS X 时不要使用大小写敏感的日志文件系统
- iOS开发_iphone开发_文件系统NSFileManager_如何创建、重命名和删除文件
- iOS开发用到的Mac系统资源库中各种文件的路径
- iOS开发-基础:获取指定路径文件大小
- Linux设备驱动开发详解--笔记5--Linux文件与设备系统
- ios开发中iphone模拟器中程序文件和数据库的存放位置
- 文件过滤系统驱动开发Filemon学习笔记
- iOS开发_iphone开发_文件系统NSFileManager_如何创建、重命名和删除文件