我想将NSMutableArray
转换(或复制?)到NSString
。我想我的问题是 ,我真的不明白NSString
的结构。转换后,我想 将其附加到电子邮件正文中。这里是我的代码:如何将NSMutableArray转换为NSString?
- (IBAction)sendEmail
{
NSLog(@"sendEmail");
[textView resignFirstResponder];
[textView1 resignFirstResponder];
if ([MFMailComposeViewController canSendMail])
{
// set the sendTo address
NSMutableArray *recipients = [[NSMutableArray alloc] initWithCapacity:1];
[recipients addObject:@"[email protected]"];
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"Iphone Game"];
NSString *string = [string appendString:[NSString stringWithFormat:"%@", [viewArray objectAtIndex:i]]];
[controller setMessageBody:string isHTML:NO];
[controller setToRecipients:recipients];
[self presentModalViewController:controller animated:YES];
[controller release];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert"
message:@"Your device is not set up for email." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
}
}
你有什么问题,你能解释清楚吗? – Dinesh 2012-04-21 08:20:34
相同是这样的:-http://stackoverflow.com/questions/8802543/how-to-convert-nsmutablearray-into-nsstring/8802630#8802630 – Leena 2012-04-21 09:51:05