Format phone number in UITextField using libPhoneNumber

780 views Asked by At

How to format any phone number with International Phone Number format in UITextField on each character input for any country using libPhoneNumber-iOS?

1

There are 1 answers

3
xi.lin On

I think you are asking how to use the libPhoneNumber-iOS? You should just read their README page which has a rich set of examples.

One basic sample is as follow:

NBPhoneNumberUtil *phoneUtil = [[NBPhoneNumberUtil alloc] init];
NSError *anError = nil;
NBPhoneNumber *myNumber = [phoneUtil parse:@"6766077303"
                          defaultRegion:@"AT" error:&anError];
if (anError == nil) {
    [phoneUtil format:myNumber 
         numberFormat:NBEPhoneNumberFormatINTERNATIONAL
                error:&anError];
}