views:

285

answers:

1

I'm working with a lot of files in my resources directory and I'd like to create folders to organise them. I've made a folder of plists, but I can't access it. Here's the code that works:

NSString *path = [[NSBundle mainBundle]
    pathForResource:@"test"
    ofType:@"plist"];

and the code that doesn't work:

NSString *path = [[NSBundle mainBundle]
    pathForResource:@"test"
    ofType:@"plist"
    inDirectory:@"plists"];

Outputting the path gives me (null). I've tried both grouping in Xcode and creating an actual folder in the Resources directory. What am I doing wrong? Thanks.

A: 

I just created a test project with that line of code, and it works fine for me. It's not even case-sensitive, so that's not the problem. All I can assume is that you're outputting the path wrong, or the resource isn't there.

When adding to Xcode, did you add the actual folder "plists" (by dragging it to the Resources group and choosing "Create Folder References for any added folders", for example)?

Have you checked the compiled app's contents to see if the "plists" folder is actually there?

andyvn22
I was missing the "Create Folder References for any added folders". Thanks very much for the answer.
nevan