Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-11-2010, 12:57 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 1
Default 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
BBlack is offline   Reply With Quote
Old 02-11-2010, 01:39 AM   #2 (permalink)
Elegance is Infinite
iPhone Dev SDK Supporter
 
TapTouchClick's Avatar
 
Join Date: Jan 2010
Location: Bay Area, CA
Posts: 677
Send a message via AIM to TapTouchClick Send a message via Skype™ to TapTouchClick
Default

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
__________________
Our website
TapTouchClick is offline   Reply With Quote
Old 02-11-2010, 01:44 AM   #3 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

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).
rocotilos is offline   Reply With Quote
Old 02-11-2010, 01:44 AM   #4 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

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).
rocotilos is offline   Reply With Quote
Reply

Bookmarks

Tags
buttons, errors, ibaction, iphone sdk

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:34 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0