Return to Snippet

Revision: 52813
at November 2, 2011 00:04 by peruggia


Initial Code
- (void)makeCall:(NSString *)number
{
	NSString *txt = number;
	NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[0-9]{4}[-]{0,1}[0-9]{4}?" options:NSRegularExpressionSearch error:nil];
	NSTextCheckingResult *result = [regex firstMatchInString:txt options:0 range:NSMakeRange(0, [txt length])];
	NSString *cleanedString = [[[txt substringWithRange:[result range]] componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789-+()"] invertedSet]] componentsJoinedByString:@""];
	NSString *escapedPhoneNumber = [cleanedString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
	NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", escapedPhoneNumber]];
	[[UIApplication sharedApplication] openURL:telURL];
}

Initial URL

                                

Initial Description

                                

Initial Title
Make a call (iPhone)

Initial Tags
iphone, ios

Initial Language
Objective C