My app displays a number of html files through a webview for information purposes. The user selects which file they need from a tableView. This code has worked well for over eighteen months now but I’m now getting the above error with certain html files. The code used is –
NSString *path = [[NSBundle mainBundle] pathForResource:@"opening_times" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:path];
The strange thing is that all files use the same code but only three out of twelve are not working. Also the code works when I use an emulator but crashes when I run the app on my phone. I’m not sure what ‘Invalid CFStringRef’ refers to but it only applies to certain files.
I would expect an encoding problem in the HTML file. For instance, if you created the HTML file on Windows, it may have assigned a “code page” that iOS can’t decode. Make sure that all of your files are UTF8-encoded.