How to programmatically create a .CSV file with string and image in iPhone?

I want to create a CSV file that contains both a string and an image. I can give input as strings separated by commas. former

NSArray  *paths  =    NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES); 
NSString *documentsDir   =    [paths objectAtIndex:0];
NSString *root   =    [documentsDir stringByAppendingPathComponent:@"products.csv"];
NSString *temp=@"jack,jil,jimmy,mike";
[temp writeToFile:root atomically:YES encoding:NSUTF8StringEncoding error:NULL];

In the above case, this works fine. Now I need to add an image with lines. I have an image as NSData. In this case, how can I give input to the CSV file.

I can also attach one image to a CSV file as NSData. former

UIImage *img = [UIImage imageNamed:@"flower.png"];
NSData *dataObj = UIImageJPEGRepresentation(img, 1.0);
[dataObj writeToFile:root atomically:YES];

My expected output should contain both an image and a string if I open the CSV file as an Excel sheet.

+5
source share
1 answer

CSV . , . Excel XML , .

+2

All Articles