Need to get button to open up mail app

Discussion in 'iOS Programming' started by andreab35, Feb 22, 2009.

  1. macrumors 6502a

    andreab35

    Joined:
    May 29, 2008
    Location:
    USA
    #1
    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:

    Code:
    #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... :eek:
     
  2. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
  3. thread starter macrumors 6502a

    andreab35

    Joined:
    May 29, 2008
    Location:
    USA
    #3
    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... :(
     
  4. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    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:
    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];
    }
    
     
  5. thread starter macrumors 6502a

    andreab35

    Joined:
    May 29, 2008
    Location:
    USA
  6. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    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.
     

Share This Page