PDA

View Full Version : Need to get button to open up mail app




andreab35
Feb 22, 2009, 01:06 PM
Hey guys!

On the FlipsideView.h, I'm trying to make a UIButton, when clicked, open up Mail in order to send a message to an email address of mine.

I have gotten some code done: but I have "error: syntax error before "*" token"

Here's the code I have so far:

#import "FlipsideView.h"

@implementation FlipsideView


- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
}
return self;
}


- (void)drawRect:(CGRect)rect {
// Drawing code
}

- (IBAction) sendEmail: (id) sender

NSURL *url = [[NSURL alloc] initWithString:@"mailto:email@gmail.com?subject=myhouse&body=suggestion that I would like to see featured."];
[[UIApplication sharedApplication] openURL:url];

{

- (void)dealloc {
[super dealloc];
}


@end

Anyone who can help me is appreciated! Thank you! :D
Sorry for being a noob- I'm still learning... :o



caveman_uk
Feb 23, 2009, 02:38 AM
You're missing a '{'.

andreab35
Feb 23, 2009, 05:28 AM
You're missing a '{'.

Haha, wow. I just figured that out myself! I was working without my glasses on and I couldn't see too well.

But my question is, is the { missing before when NSURL starts? I tried that and I got more errors.

Now I'm starting to get extremely confused for some odd reason... :(

dejo
Feb 23, 2009, 10:24 AM
But my question is, is the { missing before when NSURL starts? I tried that and I got more errors.
It's not so much missing as in the wrong place; it's the } that's missing. You need to start your block of code with the { and end it with the }. Like so:
- (IBAction) sendEmail: (id) sender
{
NSURL *url = [[NSURL alloc] initWithString:@"mailto:email@gmail.com?subject=myhouse&body=suggestion that I would like to see featured."];
[[UIApplication sharedApplication] openURL:url];
}

andreab35
Feb 23, 2009, 11:50 AM
Thank you dejo! I finally got it! No errors!

dejo
Feb 23, 2009, 11:52 AM
Thank you dejo! I finally got it! No errors!
You're welcome.

This is pretty basic Objective-C (heck, even C) coding practice, so make sure you understand the basics before proceeding much further.