Reputation: 2303
I have a simple question, but don't seem to see the answer in a previous thread, so here goes.
I want to access image files within my bundle, and the paste this string into html in various UIWebViews.
The code below seems to return a garbage string. It does not return nil, so I assume my found.
NSString *imageString = [[NSBundle mainBundle] pathForResource:@"myimage" ofType:@"png"];
Am I accessing this file correctly?
Upvotes: 1
Views: 267
Reputation: 19281
If you are inserting the string into your HTML, remember it should be a URL and not a path to a file. You may be able to simply add "file://" to the front, or you could use a NSURL object as follows:
NSString* urlString = [[NSURL fileURLWithPath:imageString] absolutePath];
Then inject urlString
into your HTML instead.
Upvotes: 1