我想將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