MppPhone

Objective-C

@interface MppPhone : NSObject
/**
 * @name MppPhone properties
 */

/**
 * Country code.
 */
@property (nonatomic, copy, readonly, nonnull) NSString *countryCode;

/**
 * Phone number
 */
@property (nonatomic, copy, readonly, nonnull) NSString *phoneNumber;


/**
 * @name MppPhone methods
 */

/**
 * Creates phone object.
 *
 * @param countryCode   Country code
 * @param phoneNumber   Phone number
 */
+ (instancetype _Nullable)phoneWithCountryCode:(NSString *_Nonnull)countryCode phoneNumber:(NSString *_Nonnull)phoneNumber;

/**
 * Creates phone object from dictionary.
 */
- (NSDictionary *_Nonnull)toDictionary;

/**
 * Verify if phone is valid.
 *
 * @return `true` if phone is valid.
 */
- (BOOL)isValid;

/**
 * Verify if phone is valid.
 *
 * @return error if phone is invalid, `nil` otherwise.
 */
- (NSError *_Nullable)validate;




@end

Swift

class MppPhone : NSObject

Undocumented

MppPhone properties

  • Country code.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly, nonnull) NSString *countryCode;

    Swift

    var countryCode: String { get }
  • Phone number

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly, nonnull) NSString *phoneNumber;

    Swift

    var phoneNumber: String { get }

MppPhone methods

  • Creates phone object.

    Declaration

    Objective-C

    + (instancetype _Nullable)phoneWithCountryCode:(NSString *_Nonnull)countryCode
                                       phoneNumber:(NSString *_Nonnull)phoneNumber;

    Swift

    convenience init?(countryCode: String, phoneNumber: String)

    Parameters

    countryCode

    Country code

    phoneNumber

    Phone number

  • Creates phone object from dictionary.

    Declaration

    Objective-C

    - (NSDictionary *_Nonnull)toDictionary;

    Swift

    func toDictionary() -> [AnyHashable : Any]
  • Verify if phone is valid.

    Declaration

    Objective-C

    - (BOOL)isValid;

    Swift

    func isValid() -> Bool

    Return Value

    true if phone is valid.

  • Verify if phone is valid.

    Declaration

    Objective-C

    - (NSError *_Nullable)validate;

    Swift

    func validate() -> (any Error)?

    Return Value

    error if phone is invalid, nil otherwise.