Well, I'm not quite sure why this is crashing down. In appearance, you are not doing anything radical. I suppose this is somehow related to the file path or to a file that does not exist there. The line that kills her is [NSURL fileURLWithPath:path] , and you can skip this line using - (NSURL *)URLForResource:(NSString *)name withExtension:(NSString *)ext subdirectory:(NSString *)subpath instead of pathForResource: . Not sure if this will solve your problem, but it's worth it.
Edit: oh, one difference between the simulator and the device is that the file system on the device is case sensitive, while it is not on the osx / simulator. Could there be a problem in your file name or file path?
Try NSLog to find out where the problem is.
NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"localHTML/mobile"]; NSLog(@"Path is %@",path); NSURL *url = [NSURL fileURLWithPath:path]; NSLog(@"URL is %@",url); NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request];
If you see "Path - null" in the console, you are pointing out something wrong in your pathForResource call.
Think:
If you added files to the Xcode project but did not include them in the build target, they will not be added to the application package.
if localHTML and mobile are “groups” in Xcode and not actual folders, then they are ignored when compiling the application. Xcode groups mean NOTHING for a compiled application (look at the folder links for creating folders in your application).
source share