2012-10-27 4 views
0

아래 코드를 구현하고 arrayPlainText을 기록했지만 시뮬레이터와 iPhone에서 실행하면 첫 번째 항목 만 표시되고 나머지는 사라졌습니다.메시지 본문의 문자열이 작동하지 않습니다.

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"); 
    } 
+0

코드를 더 제공 할 수 있습니까? 변수를 사용하여 선언을 표시하지 않습니다. –

답변

1

답은 여기에있다.

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"); 
    } 
} 
0

방법이 코드에 대한 :

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); 
+0

아니요, 결과는 같습니다. – Souljacker

+0

arrayPlainText의 내용을 인쇄하면 모든 값이 포함됩니까? – edzio27

+0

네, 모든 것이 출력되지만, 작곡가에있을 때는 그렇지 않습니다. – Souljacker

관련 문제