Reputation: 774
I implemented the code below, and logged the arrayPlainText
but when I run it in the simulator and on my iPhone it only shows the first item and everything else just disappeared.
NSMutableArray *xmlListContent;
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:[self returnListPath]])
{
xmlListContent = [[NSMutableArray alloc] initWithContentsOfFile:[self returnListPath]];
NSMutableArray *listContent = [[NSMutableArray alloc] init];
int i;
for(i = 0; i < [xmlListContent count]; i++)
{
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
[mailComposer setMailComposeDelegate:self];
if ([MFMailComposeViewController canSendMail]) {
[mailComposer setSubject:editedListTitle];
[mailComposer setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
NSString *item = [NSString stringWithString:[[xmlListContent objectAtIndex:i] objectForKey:@"label"]];
NSString *tempString = [NSString stringWithFormat:@"-%@",item];
[listContent addObject:tempString];
NSString *arrayPlainText = [listContent componentsJoinedByString:@"<br>"];
[mailComposer setMessageBody:[NSString stringWithFormat:@"<html>%@</html>",arrayPlainText] isHTML:YES];
DLog(arrayPlainText);
[self presentModalViewController:mailComposer animated:YES];
}
}
}
else
{
xmlListContent = [NSMutableArray array];
DLog(@"failed to compose list via email");
}
Upvotes: 0
Views: 144
Reputation: 996
The answer is here.
NSMutableArray *xmlListContent;
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:[self returnListPath]])
{
xmlListContent = [[NSMutableArray alloc] initWithContentsOfFile:[self returnListPath]];
NSMutableArray *listContent = [[NSMutableArray alloc] init];
int i;
for(i = 0; i < [xmlListContent count]; i++)
{
NSString *item = [[xmlListContent objectAtIndex:i] objectForKey:@"label"];
NSString *tempString = [NSString stringWithFormat:@"-%@", item];
[listContent addObject:tempString];
}
NSString *arrayPlainText = [listContent componentsJoinedByString:@"<br>\n"];
DLog(arrayPlainText);
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
[mailComposer setMailComposeDelegate:self];
[mailComposer setSubject:editedListTitle];
[mailComposer setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[mailComposer setMessageBody:[NSString stringWithFormat:@"<html>%@</html>",arrayPlainText] isHTML:YES];
[self presentModalViewController:mailComposer animated:YES];
}
else
{
xmlListContent = [NSMutableArray array];
DLog(@"failed to compose list via email");
}
}
Upvotes: 1
Reputation: 4140
How about this code:
NSString *item = [NSString stringWithString:[[self.array objectAtIndex:i] objectForKey:@"label"]];
NSString *tempString = [NSString stringWithFormat:@"-%@",item];
[listContent addObject:tempString];
NSString *arrayPlainText = [listContent componentsJoinedByString:@"<br>"];
[mailComposer setMessageBody:[NSString stringWithFormat:@"<html>%@</html>",arrayPlainText] isHTML:YES];
DLog(arrayPlainText);
Upvotes: 0