Reputation:
I want to tack one image from my resource folder. I do it like this:
NSString *fullPathToFile =[[NSString alloc]init];
fullPathToFile = [[NSBundle mainBundle] resourcePath];
fullPathToFile =[fullPathToFile stringByAppendingPathComponent:@"/groupiphonessmall.png"];
Is this correct for getting an image from the resource folder, or it gives me path of "iPhone Simulator"?
I want to send this image path to an email popup. There, I'm not getting the image.
Upvotes: 1
Views: 1382
Reputation:
I got new way to send image in email.
Tack image
Tack this image in png format and after that convert in string by base64 encoding.
You can send this base 64 image code in html formate e-mail
Here is my code:
UIImage *imageName =[UIImage imageNamed:@"groupiphonessmall.png"];
NSData *dataObj = UIImagePNGRepresentation(imageName);
NSString *imageBase64 =[self encodeBase64WithData:dataObj];
code for email:
"< img src=\"data:image/png;base64,CODEOFBASE64\ >" "
Upvotes: 0
Reputation: 55604
Can't you use [UIImage imageNamed:@"groupiphonesmall.png"];
Also when using stringByAppendingPathComponent:
you don't need to put a slash in front of the file name, it will do that for you.
Upvotes: 2
Reputation: 49354
It's a bit simpler:
NSString *pathToResourceFile = [[NSBundle mainBundle] pathForResource:@"groupiphonessmall" ofType:@"png"];
Upvotes: 2