Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arnieterm

macrumors regular
Original poster
Aug 28, 2008
201
0
I have a simple IPhone application that has two buttons
Buttons1's title is set to a telephone number
Button2 's title is set to an Email address
On clicking Button1
the below given code executes [inside button's click event]
Code:
UIButton	*btn=(UIButton*)sender;
	NSString *strPhoneNumber=[@"tel://" stringByAppendingString: btn.currentTitle ];
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:strPhoneNumber]];

Similarly for Button2's case: the below given code executes
Code:
UIButton	*btn=(UIButton*)sender;
	NSString *strPhoneNumber=[@"mailto://" stringByAppendingString: btn.currentTitle ];
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:strPhoneNumber]];

I want to know a few things
As soon as I click on either the Button1 or Button2 the application closes and nothing happens. I am running this application on IPhone and not in simulator.
Is there anything wrong with the code?
I am also not able to understand why my application closes
Can anybody explain?
Thanks
 

mstoebe

macrumors newbie
Jul 24, 2008
12
0
Germany
I don't have an exact solution for you but have you tried NSLogging your strings to make sure they are correct?

Furthermore, your Application quits because you send the system a request to handle a URL. For "tel://"-URLs this is the Phone-Application, for "Mailto:"-URLs it's the MobileMail-App. So, what you should be seeing is that your App quits and the other app opens to handle your request. That's how it is supposed to work!

What were you hoping for instead? What are you trying to accomplish?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.