SINPhoneNumberUtil Protocol Reference
| Conforms to | NSObject |
|---|---|
| Declared in | SINPhoneNumberUtil.h |
– parse:defaultRegion:error:
required method
Parses a string as a phone number. The phone number is an opaque type
- (nullable id<SINPhoneNumber>)parse:(NSString *)string defaultRegion:(NSString *)isoCountryCode error:(NSError **)errorParameters
string |
input to parse. |
|---|---|
isoCountryCode |
default region as ISO-3166-1 country code. |
error |
will be assigned if the string cannot be parsed as a valid phone number. |
Return Value
a phone number instance, or nil if the input cannot be parsed as a valid phone number.
See Also
To format the parsed phone number, use [SINPhoneNumberUtil formatNumber:format:].
Declared In
SINPhoneNumberUtil.h
– formatNumber:format:
required method
Format a phone number in the specified format.
- (NSString *)formatNumber:(id<SINPhoneNumber>)phoneNumber format:(SINPhoneNumberFormat)formatParameters
phoneNumber |
a phone number instance. |
|---|---|
format |
a format specifier, e.g. E.164, National or International format. |
Return Value
formatted string. Returns empty string if input is invalid.
Declared In
SINPhoneNumberUtil.h
– exampleNumberForRegion:
required method
Get an example phone number.
- (nullable id<SINPhoneNumber>)exampleNumberForRegion:(NSString *)isoCountryCodeParameters
isoCountryCode |
region as ISO-3166-1 country code. |
|---|
Return Value
example phone number. May return nil if the input region country code is invalid.
Discussion
Defaults to returning a Mobile example number.
Declared In
SINPhoneNumberUtil.h
– isPossibleNumber:fromRegion:error:
required method
Checks whether input is a possible phone number, given a country code where the number would be dialed from.
- (BOOL)isPossibleNumber:(NSString *)string fromRegion:(NSString *)isoCountryCode error:(NSError **)errorParameters
string |
input as an NSString*. |
|---|---|
isoCountryCode |
region as ISO-3166-1 country code where the number will be dialed from. |
error |
that will be assigned if the string cannot be parsed as a phone number. |
Discussion
Note that even if this method indicates that the input is a possible phone number, it doesn’t necessarily mean it’s a valid phone number. I.e. this is a less strict check.
Declared In
SINPhoneNumberUtil.h
– isPossibleNumber:error:
required method
Checks whether input is a possible phone number.
- (BOOL)isPossibleNumber:(id<SINPhoneNumber>)phoneNumber error:(NSError **)errorParameters
phoneNumber |
input as a parsed idSINPhoneNumber |
|---|---|
error |
that will be assigned if the string cannot be parsed as a phone number. |
Return Value
indication of whether the input is a possible / viable phone number.
Discussion
Note that even if this method indicates that the input is a possible phone number, it doesn’t necessarily mean it’s a valid phone number. I.e. this is a less strict check.
Declared In
SINPhoneNumberUtil.h
– countryCallingCodeForRegion:
required method
Get a country calling code given a ISO-3166-1 country code.
- (nullable NSNumber *)countryCallingCodeForRegion:(NSString *)isoCountryCodeParameters
isoCountryCode |
region as ISO-3166-1 country. |
|---|
Return Value
Country calling code corresponding to the given region. Return nil in case of failure.
Declared In
SINPhoneNumberUtil.h
– regionListWithLocale:
required method
Returns a region / country list structure that contains info on all countries / regions available by NSLocale.ISOCountryCodes. Each entry in the list provides info such as ISO 3166-1 country code, country dialing code, and country display name (according to the given locale).
- (id<SINRegionList>)regionListWithLocale:(NSLocale *)localeParameters
locale |
locale that will be used to derive a display name for the region / country. |
|---|
Declared In
SINPhoneNumberUtil.h