Application crashes at [[NSBundle mainBundle] pathForResource

懵懂的女人 提交于 2019-12-14 02:54:26

问题


My Application is crashes in the device at this point,

[[NSBundle mainBundle] pathForResource

I am giving the path for the pdf here . but at the execution time it is showing that it is not getting path there . and that may be the reason for crashing.

however it is running perfectly on simulator .

i am not able to figure out why is this happening

here is that code

NSString *path = [[NSBundle mainBundle] pathForResource:[myArray objectAtIndex:0] ofType:[myArray objectAtIndex:1]];
NSLog(@"array elemt :%@", [myArray objectAtIndex:0]);
NSLog(@"array elemt 1 :%@", [myArray objectAtIndex:1]);
NSLog(@"path is :%@",path);
NSLog(@"responds to selector mainBundle=%@",[NSBundle respondsToSelector:@selector(mainBundle)]?@"YES""NO");
NSURL *targetURL = [NSURL fileURLWithPath:path];

in this log of the path - when i use device it is showing me nil and when i use simulator it is showing me the path . and it is showing me that is is crashing on NSURL line


回答1:


I've found that when something like this works on the simulator, but not on the device, it's likely a problem with the case of the string. Your device is case sensitive but not your computer. Check your string of the file name or the type.



来源:https://stackoverflow.com/questions/7510717/application-crashes-at-nsbundle-mainbundle-pathforresource

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!