Articles

iOS 5模拟器的一个Bug

在开发GeekVocab的过程中我遇到一个奇怪的问题,在iOS 5模拟器中运行的好好的,可是在iOS 6模拟器中却会出现如下错误:

GeekVocab[2043:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/Lionel/Library/Application Support/iPhone Simulator/6.1/Applications/85D72095-838F-4E25-B5B7-72F874ED0610/GeekVocab.app> (loaded)' with name 'GvSettingViewController''
*** First throw call stack:
(0x203d012 0x151fe7e 0x203cdeb 0x67fef9 0x5447e7 0x544dc8 0x544ff8 0x545232 0x32a16 0x328f9 0x5451c7 0x545232 0x5454da 0x55c8e5 0x55c9cb 0x55cc76 0x55cd71 0x55d89b 0x55d9b9 0x55da45 0x66320b 0x4b42dd 0x15336b0 0x6fcbfc0 0x6fc033c 0x6fcbeaf 0x5532bd 0x49bb56 0x49a66f 0x49a589 0x4997e4 0x49961e 0x49a3d9 0x49d2d2 0x54799c 0x494574 0x49476f 0x494905 0x49d917 0x2300 0x461157 0x461747 0x46294b 0x473cb5 0x474beb 0x466698 0x2276df9 0x2276ad0 0x1fb2bf5 0x1fb2962 0x1fe3bb6 0x1fe2f44 0x1fe2e1b 0x46217a 0x463ffc 0x1f92 0x1ec5)
libc++abi.dylib: terminate called throwing an exception

仔细对比后发现实际nib文件名与代码中的大小写不一致,代码中写的是:

GVSettingViewController *settingViewController = [[GVSettingViewController alloc] initWithNibName:@"GvSettingViewController" bundle:nil];

而实际的nib文件名是GSettingViewController.nib,有一个字母大小写不一致。经过测试,在调用initWithNibName:bundle:时,iOS 5.0, 5.1模拟器不区分nib文件名大小写,而iOS 6.1模拟器以及装有iOS 5.11、iOS 6.13的真实设备上都是区分大小写的。