I have a scorekeeping app that has variables for team names, score, etc. I would like to be able to take the data stored in those variables and send it via email to whomever. In other words, when the game is complete you can choose to send an email to a friend/family member with the team names and score already filled in the text of the email. I would rather it not be sent as an attachment. I know how to specify a subject and body, but not how to populate the body with the data from the app (which doesn’t get stored). The code I’m using:
- (IBAction)email:(id)sender {
MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
[composer setMailComposeDelegate:self];
if ([MFMailComposeViewController canSendMail]){
[composer setToRecipients:[NSArray arrayWithObject:@"", nil]];
[composer setSubject:@"Game Results Provided by Simple-Score"];
[composer setMessageBody:@"" isHTML:NO];
[composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:composer animated:YES];
}
The problem I run into, my normal way of displaying an int which would be:
[composer setMessageBody:@"%i", variable];
gives the error “no visible @interface for ‘MFMailComposeViewController’ declares the selector ‘setMessageBody'” instead of the output i want. If I enter static text in the setMessageBody field, it displays fine.
setMessageBodydoesn’t take a format string as an argument, so this is wrong:It takes an
NSStringobject as an argument, so you want something like this:Obviously assuming that
variableis the right type.