I want to do the following. I have an array of objects (businesses) and each business has its own details including their telephone numbers.
I know how to make a call in Objective-C but I don't know how to update the numbers dynamically. I have a Details class (.h and .m) and I have declared tel as a variable.
So to make a call I would use below as an example
-(IBAction)MakePhoneCall:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:123456"]];
}
I use a DetailViewController so I have a list of businesses that gets populated and depending on the business selected, that business object is created. So for my tel I want to do the following:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:" + detail.tel]];
But this obviously doesnt work. Can anyone please tell me how this is done?
if you're making a call from your application and you want the user back into the application after the end of the call then use telprompt: instead of tel: like below
-(IBAction)MakePhoneCall:(id)sender
{
NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:#"telprompt://%#",detail.tel]];
[[UIApplication sharedApplication] openURL:URL];
}
I would create a [NSString stringWithFormat], then plug that in the "URLWithString".
-(IBAction)MakePhoneCall:(id)sender
{
NSString *string = [NSString stringWithFormat:#"tel:%#", detail.tel];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:string];
}
Hope that helps.
Related
here is the scenario:
I have fetched the iphone contact details into my application.And i have displayed email,phone details my View controller.
Now,I want to know how to invoke call event which i click on phone number in my application?
Well you just call the tel scheme:
NSURL *phoneURL = [NSURL URLWithString:#"tel:1234564897"];
BOOL hasPhone = [[UIApplication sharedApplication] canOpenURL:phoneURL];
if (hasPhone) {
[[UIApplication sharedApplication] openURL:phoneURL];
}
Apple URL scheme Reference
NSString *phoneNumber = #"tel://1234567890"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
Try with
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://123456789"]];
I want to implement a contact us page where there are few phone numbers, and i want to call the number when the user clicks on them. So i decided to create buttons with the phone number as their title.
For the button click methods i have something like this
-(IBAction)numberClicked:(id)sender;
For initiation a call i know i can use this
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel:%#", phoneNumber]]];
My question is how should i modify the method so that it can take the phone number(title of te button) as argument.
Help would be appreciated.
Try
NSString *phoneNumber = [sender currentTitle];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel:%#", phoneNumber]]];
In my app i need a map to loaded by passing address,city, state province code and postal code.
Can any one tell me how can i do it??
You can use below :-
NSString* yourFullAddress = #"address,city, state province code and postal code";
yourFullAddress = [yourFullAddress stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
// Now create the URL string ...
NSString* urlString = [NSString stringWithFormat:#"http://maps.google.com/maps?q=%#", yourFullAddress];
// An the final magic ... openURL!
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
Or in case u dont want to open google maps and rather set the coordinates on ur MKMapView ... u can GeoCode ur address to get the coordinates and finally set the coordinate region on ur MKMapview ..
Did you even try searching on Google or SO?
A good start would be here http://blog.objectgraph.com/index.php/2009/04/02/iphone-sdk-30-playing-with-map-kit/
I'm trying to format a URL string however it's saying there are too many arguments. My code is below:
-(IBAction)tweetRandom {
//NSLog(#"CALLED");
test = 100;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://twitter.com/%i", test]]; // problem line
}
Anyone know how to format the URL? Was hoping there was something by the name of URLWithFormat but it doesn't exist.
You need to use stringWithFormat: like this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://twitter.com/%i", test]]];
I need that I can use 1 object of NSString to use in all other files
to access 1 variable in all filees
Make this NSString a property of the AppDelegate class (or whatever your application delegate class is named). If the property is named myString, you can then access it via:
[[[UIApplication sharedApplication] delegate] myString];
To avoid warnings, you may want to import the AppDelegate class:
#import "AppDelegate.h"
...and expand the first code snippet into:
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate myString];
That's an unclear question.
If I understand correctly you want to have an global NSString* shared by multiple files. In that case, in one of the source files (.m), insert
NSString* my_global_string = #"...";
and in all other source files (or in a common .h), insert
extern NSString* my_global_string;