B beesbane macrumors newbie Original poster Oct 16, 2010 21 0 Oct 30, 2010 #1 What is wrong with this? Code: PhoneNum.text = [[NSString alloc] initWithFormat:@"Phone:",[PhoneData valueForKey:@"number"]]; I can't figure how to write it right.
What is wrong with this? Code: PhoneNum.text = [[NSString alloc] initWithFormat:@"Phone:",[PhoneData valueForKey:@"number"]]; I can't figure how to write it right.
robbieduncan Moderator emeritus Jul 24, 2002 25,611 893 Harrogate Oct 30, 2010 #2 There are no formatting placeholders in the string?
B beesbane macrumors newbie Original poster Oct 16, 2010 21 0 Oct 30, 2010 #3 Like for example...? Is there a better or simpler way for me to do this?
robbieduncan Moderator emeritus Jul 24, 2002 25,611 893 Harrogate Oct 30, 2010 #4 beesbane said: Like for example...? Is there a better or simpler way for me to do this? Click to expand... Open the NSString documentation, go to initWithFormat: section. Read what it says. Follow the Formatting String Objects link for examples and the String Format Specifiers for a list of all the accepted format placeholders. If you still need examples I suggest Google will provide thousands.
beesbane said: Like for example...? Is there a better or simpler way for me to do this? Click to expand... Open the NSString documentation, go to initWithFormat: section. Read what it says. Follow the Formatting String Objects link for examples and the String Format Specifiers for a list of all the accepted format placeholders. If you still need examples I suggest Google will provide thousands.
B beesbane macrumors newbie Original poster Oct 16, 2010 21 0 Oct 30, 2010 #5 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]]; }
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]]; }
B beesbane macrumors newbie Original poster Oct 16, 2010 21 0 Oct 30, 2010 #6 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]];
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]];
robbieduncan Moderator emeritus Jul 24, 2002 25,611 893 Harrogate Oct 30, 2010 #8 beesbane said: Thanks for your help Click to expand... No worries, good to hear you've got it working. I've asked the moderators to move this to iPhone Programming. I'd suggest you might want to post future threads of a similar nature in there.
beesbane said: Thanks for your help Click to expand... No worries, good to hear you've got it working. I've asked the moderators to move this to iPhone Programming. I'd suggest you might want to post future threads of a similar nature in there.