NSString(VOPhoneNumberFormatter)

@interface NSString (VOPhoneNumberFormatter)

Category to help with phone number formatting and validation.

  • Converts an unformatted string to a formatted phone number string.

    Declaration

    Objective-C

    - (NSString *)formatPhoneNumberStringWithFormat:(VOPhoneNumberFormat)format;

    Swift

    func formatPhoneNumber(with format: VOPhoneNumberFormat) -> String!

    Parameters

    format

    - The format the phone number string should be converted to.

    Return Value

    Formatted phone number string. If the phone number is invalid, it will return the original unformatted string.

  • Checks if the string is a valid phone number.

    Declaration

    Objective-C

    - (BOOL)isValidPhoneNumber;

    Swift

    func isValidPhoneNumber() -> Bool

    Return Value

    YES if phone number is valid, NO otherwise.