Reputation: 2122
Have the folder structure like
*Resources/books/CD_en/icon/0.jpg;
*Resources/books/CD_en/icon/1.jpg;
*Resources/books/DD_en/icon/0.jpg;
*Resources/books/DD_en/icon/1.jpg;
how to get resource path from NSBundle
using the subpath 'books/CD_en/icon/0.jpg'
I tried using,
- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)extension inDirectory:(NSString *)subpath
[[NSBundle mainBundle] pathForResource:@"0.jpg" ofType:@"jpg" inDirectory:@"books/CD_en/icon"];
but it returns nil
.
Upvotes: 7
Views: 4651
Reputation: 2784
i got same problem to retrive image from Resource
folder. Adding image by following method solved my problem.
Add Files to "project name"
.Copy items into destination group's folder
and Create Folder References for any added folders
and Add to targets
.Add
.Then with bellow code i can retrive my image.
[[NSBundle mainBundle] pathForResource:@"imageName" ofType:@"png"];
Upvotes: 1
Reputation: 2122
I got it. Simply we need the add the folder structure 'books/...' to the app Resource folder. Which will display in blue color.
Then the existing code is running successfully.
Thanks to yehnan.
Upvotes: 2