Archive for November 15th, 2008

15
Nov

Snippet: Phone number

Quick one liner for you today: Ever wondered how to retrieve the user’s phone number programmatically? Well, here’s the trick:

   id number = [[NSUserDefaults standardUserDefaults] objectForKey:@”SBFormattedPhoneNumber”];

   NSLog(@”user phone number is %@”, number);

Run that and you’ll get output like
user phone number is 1 (555) 555-5555

Beats the heck out of asking the user to select their own address book entry or something like that, doesn’t it now?

h/t: iphonesdk!