Unified Contacts

Showing posts with label NSString. Show all posts
Showing posts with label NSString. Show all posts

11 April, 2014

Call URL: tel vs telprompt

Both tel: and telprompt: can make a phone call. But what is the difference?

For tel:, iPhone will make the call immediately and will state in Phone app after the call.

For telprompt:, iPhone will ask whether you want call this number and will return to your app after the call.

Be aware that sometimes address book returns the phone number with white space or non-break space. It causes the NSURL returns null. The following code can filter out these 2 types of space.

NSString *phoneNumberString = [[self.tableView.detailTextLabel.text componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:@""];

07 March, 2014

Simple way to create NSString & NSArray

There are several ways available to create NSString & NSArray, but sometimes you may think those methods are too long that decreases the readability of your code. Here are 2 simple ways to create NSString and NSArray.

NSString *string1 = @"string1";
NSString *string2 = @"string2";
NSArray *array = @[string1, string2];