tags:

views:

24

answers:

2

Hi, I am using following code to make a phone call from my iPhone app:

NSURL *myPhone1 = [NSURL URLWithString:@"14165551212"];
[myPhone1 scheme:@"tel://"];
NSURLRequest *myPhoneReq = [[NSURLRequest alloc ] requestWithURL:myPhone1];
NSURLConnection *myCon = [[NSURLConnection alloc] initWithRequest:myPhoneReq delegate:self];

but getting following error: 'NSInvalidArgumentException', reason: '-[NSURL scheme:]: unrecognized selector sent to instance 0x6a10ba0

Any idea how to achieve this?

A: 

All you need to do is this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://14165551212"]]

That might fix your problem, however it won't work in the iPhone simulator.

esqew
I tried it, no error but I am not able to see any call happening on simulator the way you can see on Android simulator? Does it behave differently? No change on simulator?
Abhinav
I *said* it won't work on the iPhone simulator.
esqew
+2  A: 
[[UIApplication sharedApplication] 
                    openURL:[NSURL URLWithString:@"tel: 14165551212"]];

will not work in simulator

Aaron Saunders
What Aaron says. NSURL does not have a `scheme:` method. It does have a `scheme` method (without a parameter). http://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html#//apple_ref/occ/instm/NSURL/scheme
Robot K