2013-01-06 1 views
0

나는 앱을 만들고 있었는데 누군가가 내 앱에서 이메일을 통해 공유하고 싶을 때 문자열로 stringValue을 변수로 표시하고 싶었습니다.MailComposeViewController에 문자열 인쇄하기

- (IBAction)openMail:(id)sender { 
    if ([MFMailComposeViewController canSendMail]) 
    { 
     MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; 
     mailer.mailComposeDelegate = self; 
     [mailer setSubject:@"My App"]; 
     NSArray *toRecipients = [NSArray arrayWithObjects:@"[email protected]", nil]; 
     [mailer setToRecipients:toRecipients]; 
     NSString *emailBody = [@"Rating is: %@", [self.app.rating stringValue]; 
     [mailer setMessageBody:emailBody isHTML:NO]; 
     [self presentModalViewController:mailer animated:YES]; 
    } 

가 어떻게 표시 할 [self.app.rating stringValue]; 할 수있다 "평가는 다음과 같습니다 some_number"당신 OpenMail 등은? 아마도 %@ 부분을 잘못 쓰고 있습니까? 어떤 도움을 주시면 감사하겠습니다. 미리 감사드립니다!

답변

1
[NSString stringWithFormat:@"Rating is: %@", [self.app.rating stringValue]]; 

트릭을 할 것입니다은 %@ 지정이 NSNumber 등 같은 다른 코코아 객체에 대한 잘 작동 것이지만 [self.app.rating stringValue]이 (유효한 NSString 객체를 반환 제공, 그래서 self.app.ratingNSNumber 경우 당신도 보내지 않고 문자열을 포맷 할 수 stringValue 메시지). 시도 당신이 애플의 documentation here

0

에 모습을 가질 수 서식 문자열에 대한 자세한 내용은

다음

NSString *emailBody = [NSString stringWithFormat:@"Rating is: %@", [self.app.rating stringValue]; 

[self.app.rating]을 위의 코드를 사용하여, 문자열을 반환해야 .

도움이 되시길 바랍니다.

0

당신이 stringWithFormat:

을 떠나이 필요합니다

NSString *emailBody = [NSString stringWithFormat:@"Rating is: %@", [self.app.rating stringValue]];