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

beesbane

macrumors newbie
Original poster
Oct 16, 2010
21
0
What is wrong with this?

Code:
PhoneNum.text = [[NSString alloc] initWithFormat:@"Phone:",[PhoneData valueForKey:@"number"]];

I can't figure how to write it right.
 
Like for example...?

Is there a better or simpler way for me to do this?
 
Alright, I've gotten it to work now. As long as it is set up in viewDidLoad and on a label, it works.

How can I set it up in an IBAction?

Code:
-(IBAction) phoneBtn{
	
	NSString *phoneString = [NSString localizedStringWithFormat:@"%@  %@\n", @"tel://", [MasterData valueForKey:@"Phone"]];
	
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneString]];
	
}
 
Oops... I feel a bit silly. I had a double space in the URL. Of course it wouldn't work.

Writing it like this worked:

Code:
NSString *phoneString = [NSString localizedStringWithFormat:@"%@%@\n", @"tel://", [dvdData valueForKey:@"Phone"]];
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneString]];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.