我是 iOS 开发新手,正在开发我的第一个应用程序。我有一段代码,假设在我共享它时将数据从我的 NSMutableArray 添加到电子邮件正文。我遇到了一个问题,数组描述只打印出数据的地址而不是实际数据。我知道这是预期的行为,我如何在电子邮件正文中显示数组的内容?
这是我写的代码:
- (void)displayMailComposerSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Attendance"];
NSString *data = [self.attendItems description];
[picker setMessageBody:data isHTML:NO];
[self presentViewController:picker animated:YES completion:NULL];
}
最佳答案
代替
NSString *data = [self.attendItems description];
使用类似的东西:
NSString *data = [self.attendItems componentsJoinedByString:@", "];
数组中的所有值将由逗号 (,) 连接。
关于ios - 将 NSMutableArray 打印到电子邮件正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21114130/