免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1631 | 回复: 1
打印 上一主题 下一主题

iOS开发笔记:大小写敏感的iOS文件系统,而iOS模拟器竟然对大小写不敏感 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-03-04 14:55 |只看该作者 |倒序浏览
iOS开发笔记:大小写敏感的iOS文件系统,而iOS模拟器竟然对大小写不敏感








一个程序在模拟器上运行正常,但在真机上运行就是出错,排除了下列多种可能性:

(1)用5.0的SDK开发,部署在4.3的真机系统上

(2)越狱的iPhone机器

(3)文件的汉字编码不正确

(4)ZIP文件包解压到iPhone机器里有问题

(5)苹果开发证书安装不正确

最后发现是该死的iOS文件系统竟然对大小写敏感!!!从网上查了一下,在这篇文章里有清楚的描述,原话是这样的:

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过来的程序员们经常忽略这个问题(我就是这样),这也是要经常地、尽早地进行真机调试的一个主要原因。

另外得到的一个小经验就是要对NSError的错误信息进行检查。

NSError *error = nil;

NSString *str = [[NSString alloc] initWithContentsOfFile:path encoding:enc error:&error];

要检查一下error对象,或者检查一下str对象,尽早发现错误。

论坛徽章:
0
2 [报告]
发表于 2012-03-04 14:55 |只看该作者
谢谢分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP