Hey guys I need to send the content of an NSMutableArray through email. I have a mailing function but I’m not sure on how to place the content of the array into a NSString to be displayed on the email under each other. Is there a way to place all the content of the array into the string with maybe HTML nextline command between each array element?
NSString *emailBody = @"Need to put the body here";
Thanks
The simplest way is to call the array’s
descriptionmethod which will return a human readable plist in a NSString.If you need to reconstitute the array from the email. You will need save the array as xml plist using the
writeToFile:method. Then read the file back in as a string. To reconstitute you will need to extract the xml from the email, put it in a NSString, write that to file, then read it back into an NSArray.(IIRC, there used to be a way to write to NSString as if it was a file but I can’t remember how to do it anymore. Probably, writing to a NSFileHandle and reading it back instantly.)
Edit:
Like so:
…prints:
For your project you can do:
The is also a
descriptionWithLocalethat will print the array in different languages. I don’t have a ready example for that. See NSArray, NSLocale and The Locales Programming Guide