In my code I want to open a html file, so added the following line of code:
NSString* path = [[NSBundle mainBundle] pathForResource:@"cheese" ofType:@"html"];
But it fails as path is nil after execution. The file cheese.html exists and has been added to the project's resources.
I couldn't, and still can't figure out why its not working. I have a few other projects that open and read files so as an experiment I copied the line of code that is failing to one of these other projects, and along with it I dragged/dropped the cheese.html file from the project where it doesn't work to this other project (dragged and dropped from within xcode's hieararchical project file view), and bingo - the line executes and path is not nil in that other project.
So I'm totally mystified, why is it working in one project but not another?
Its the exact same line of code in both, and as the file was dragged and dropped its the same file, and as the file was dragged from within xcode itself, it proves the file has been added to the projects resources. So why would it still fail?