My app is a single window app currently with a text label and a button. When you press the button the text label updates with random text from a local database. I'd like to add the functionality to e-mail the current display text with a separate e-mail button down below. I am posting the current button functionality and was looking for some assistance to see if it is possible to capture the current displayLabel text with a new button.
Current code:
Code:
/*!
@function tapButtonPressed
@discussion This function is called when "Tap Me Now" button is pressed
@param sender
@result displays the random text from the database in Label
*/
-(IBAction)tapButtonPressed:(id)sender
{
ShakeMeAppDelegate *appDelegate = (ShakeMeAppDelegate *)[[UIApplication sharedApplication] delegate];
NSInteger randomNumber = [self getRandomIndex];
//NSLog(@"Selected shake text is %@", [[appDelegate.shakeTexts objectAtIndex:randomNumber] text]);
displayLabel.text = [[appDelegate.shakeTexts objectAtIndex:randomNumber] text];
}
you do realise that you need to somehow capture the mail recipient address, right?
generally you can use the "mailto:" URL scheme to send mails (and include your text in the body of the message). Be aware that this will close your program and open mobile mail.
Can I just pass the subject and body text and have the user enter the To: address once they are passed to the mail app, or does the url just call the mail app and everything has to be pre-entered?
@"mailto:?subject=<escaped subject>&body=<escaped body text>"
This will launch mobile mail with the subject and body prepopulated. The user must then pick one or more email addresses and tap the Send button.
That would work just fine to start until I can mess around with the other sdk which will allow you to send e-mails from within the application. Does anyone have any suggestion on how I can get the displayLabel.text value into the body string of the e-mail url? I'm sorry if this is really simple, but this is my first app and everything is still very confusing to me lol.
My app is a single window app currently with a text label and a button. When you press the button the text label updates with random text from a local database. I'd like to add the functionality to e-mail the current display text with a separate e-mail button down below. I am posting the current button functionality and was looking for some ***istance to see if it is possible to capture the current displayLabel text with a new button.
Current code:
Code:
/*!
@function tapButtonPressed
@discussion This function is called when "Tap Me Now" button is pressed
@param sender
@result displays the random text from the database in Label
*/
-(IBAction)tapButtonPressed:(id)sender
{
ShakeMeAppDelegate *appDelegate = (ShakeMeAppDelegate *)[[UIApplication sharedApplication] delegate];
NSInteger randomNumber = [self getRandomIndex];
//NSLog(@"Selected shake text is %@", [[appDelegate.shakeTexts objectAtIndex:randomNumber] text]);
displayLabel.text = [[appDelegate.shakeTexts objectAtIndex:randomNumber] text];
}
Does the email function need to go within the button tap function, or can i just reference the displayLabel.text in a separate button press function?