02-11-2010, 12:57 AM
#1 (permalink )
Registered Member
Join Date: Feb 2010
Posts: 1
Brand New, Wanting To Learn, Simple Question
I am working on my first iPhone app and I've run into a problem.
Where I'm at so far: I've created a view-based app with 4-6 simple buttons. I want one of those buttons to call a pre-determined phone number using the devices' built in phone app.
I've got the buttons. I've got the IBActions set. I just can't seem to figure out the code to get the button to actually make the call.
Here is what my button code looks like so far
-----------------------------------------------------------------------------------
IBOutlet UIButton *blogButton;
IBOutlet UIButton *contactButton;
IBOutlet UIButton *distressButton;
IBOutlet UIButton *flickrButton;
IBOutlet UIButton *homepageButton;
IBOutlet UIButton *pressreleaseButton;
IBOutlet UIButton *youtubeButton;
}
- (IBAction)blogButtonPressed;
- (IBAction)contactButtonPressed;
- (IBAction)distressButtonPressed:(id)sender; {
[[UIApplication sharedApplication] openURL:[NSURLWithString:@"tel://12169026117"]]
}
- (IBAction)flickrButtonPressed;
- (IBAction)homepageButtonPressed;
- (IBAction)pressreleaseButtonPressed;
- (IBAction)youtubeButtonPressed;
@end
---------------------------------------------------------------------------
And here are the error messages I get when I attempt to 'build and go:'
ViewController.h:22:sninth error: expected identifier or '(' before '{' token
and
AppDelegate.m:22: error: expected identifier or '(' before '{' token
Can anyone help me? Maybe even pass along some code that will cause my button to make a phone call.
Thank you!
Last edited by BBlack; 02-11-2010 at 01:01 AM .
Reason: remove smilies
02-11-2010, 01:39 AM
#2 (permalink )
Elegance is Infinite
iPhone Dev SDK Supporter
Join Date: Jan 2010
Location: Bay Area, CA
Posts: 677
I'd highly recommend getting a book as your problem here is very basic and is usually in the first few chapters of any book.
.h
Code:
IBOutlet UIButton *blogButton;
IBOutlet UIButton *contactButton;
IBOutlet UIButton *distressButton;
IBOutlet UIButton *flickrButton;
IBOutlet UIButton *homepageButton;
IBOutlet UIButton *pressreleaseButton;
IBOutlet UIButton *youtubeButton;
}
- (IBAction)blogButtonPressed;
- (IBAction)contactButtonPressed;
- (IBAction)distressButtonPressed:(id)sender;
- (IBAction)flickrButtonPressed;
- (IBAction)homepageButtonPressed;
- (IBAction)pressreleaseButtonPressed;
- (IBAction)youtubeButtonPressed;
@end
.m
Code:
- (IBAction)distressButtonPressed:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURLWithString:@"tel://12169026117"]];
}
but honestly, get a book.
HTH
02-11-2010, 01:44 AM
#3 (permalink )
indie dev
Join Date: Oct 2009
Posts: 2,754
You need to read more about how to write codes from books or the internet.
This is totally wrong syntax:
Code:
- (IBAction)distressButtonPressed:(id)sender; {
[[UIApplication sharedApplication] openURL:[NSURLWithString:@"tel://12169026117"]];
}
And this code I believe is not in the right file either. The place where you declare IBOutlets and IBActions is in the header (.h) file. And the place where you write codes are in Main file (.m).
02-11-2010, 01:44 AM
#4 (permalink )
indie dev
Join Date: Oct 2009
Posts: 2,754
You need to read more about how to write codes from books or the internet.
This is totally wrong syntax:
Code:
- (IBAction)distressButtonPressed:(id)sender; {
[[UIApplication sharedApplication] openURL:[NSURLWithString:@"tel://12169026117"]];
}
And this code I believe is not in the right file either. The place where you declare IBOutlets and IBActions is in the header (.h) file. And the place where you write codes are in Main file (.m).
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 251
26 members and 225 guests
ADY , AragornSG , bookesp , chillyh , ckgni , dacapo , Dani77 , Davey555 , Desert Diva , Dominus , glenn_sayers , HemiMG , JasonR , LEARN2MAKE , M.A.S. , marshusensei , mer10 , nobre84 , Oral B , prchn4christ , Raggou , Rudy , ryantcb , themathminister , theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp