Reputation: 16402
I've a plist file that sits in a directory called Templates of my .app directory. This plist file is loaded thus without any problems:
NSDictionary *sqlPropertyList = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:CH_PQ_QUERIES ofType:@"plist"]];
I created a .txt file in the same directory and tried to load it the same way:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"excel2004" ofType:@"xml"];
But filePath
was always null, even though the bundled appeared to be loaded.
What's going on here? Why are plists allowed to sit in subdirectories and other files not? Is the plist file being loaded by accident and I shouldn't rely on this behaviour?
Thanks
Upvotes: 1
Views: 610
Reputation: 26859
This might be a silly question, but you say you created a "txt" file but your call to pathToResource:ofType:
specifies xml
as the type. Is that correct? And, of course, any files like these need to be in the Resources
directory of your app bundle.
Upvotes: 2