nevan king
nevan king

Reputation: 113777

How can I organise my resources into folders?

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.

Upvotes: 1

Views: 937

Answers (1)

andyvn22
andyvn22

Reputation: 14824

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?

Upvotes: 1

Related Questions