Differences in accessing resources between Simulator and Device?
- by Tony
Is there some difference between the way that bundle resources can be accessed on the iPhone simulator versus a device (in my case, an iPad)? I am able to access a file on the former, but not the latter.
NSString *filePath = [NSString stringWithFormat:@"%@%@",[[NSBundle mainBundle] bundlePath], @"/AppResources/html/pages/quickHelp.html"];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath];
// fileExists == YES in the debugger on both the simulator and the device
NSString *path = [NSString stringWithFormat:@"AppResources/html/pages/%@", contentsFileName];
NSString *pathForURL = [[NSBundle mainBundle] pathForResource:path ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:pathForURL isDirectory:NO];
The code above works fine in the simulator, but on the device pathForResource:path returns nil, so the last line throws a 'nil string parameter' exception.
Am I missing something obvious?
edit: Of course, in the above @"quickHelp" is being passed in the contentsFileName var.
edit2: if it makes any difference, in my build settings "Base SDK" is set to "iPhone Device 4.0", and "iPhone OS Deployment Target" is set to "iPhone OS 3.1.3". Any other settings that might have an influence?