prajakta
prajakta

Reputation: 673

access images from resource folder on iphone

I have folder inside reource folder lets say

resource->folder A->61.png

so how to access this path I did this

NSString *myFilePath=   [[NSBundle mainBundle] pathForResource:@"61" ofType:@"png" inDirectory:@"A" ];

NSLog(@"file is at %@",myFilePath);// its null

why my path is null?

Upvotes: 0

Views: 916

Answers (2)

prajakta
prajakta

Reputation: 673

This is the answer for anyone who is looking for it.

You need to import the directory into your app using the following method:

  1. Create a Directory on your Mac.
  2. Select to Add Existing Files to your project
  3. Select the Directory you want to import
  4. In the pop-up window make sure you select "Copy items into destination group's folder" and "Create Folder References for any added folders"
  5. Hit "Add"

You’re done!

Upvotes: 2

taskinoor
taskinoor

Reputation: 46037

You do not need to use inDirectory. Even if you create directory under resource folder, all resources go to a flat directory under app bundle.

NSString *myFilePath=   [[NSBundle mainBundle] pathForResource:@"61" ofType:@"png"];

Upvotes: 1

Related Questions