diff --git a/Example/Info.plist b/Example/Info.plist index c169bce..5036990 100644 --- a/Example/Info.plist +++ b/Example/Info.plist @@ -15,7 +15,7 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>2.0.0</string> + <string>2.0.1</string> <key>CFBundleVersion</key> <string>1</string> <key>LSRequiresIPhoneOS</key> diff --git a/NKVPhonePicker.podspec b/NKVPhonePicker.podspec index 5e2e794..40855d3 100755 --- a/NKVPhonePicker.podspec +++ b/NKVPhonePicker.podspec @@ -7,7 +7,7 @@ Pod::Spec.new do |s| s.name = 'NKVPhonePicker' - s.version = '2.0.0' + s.version = '2.0.1' s.summary = 'A UITextField subclass to simplify the selection of country codes.' s.description = <<-DESC With this pod you can easily select country codes with just making your textFields class - the NKVPhonePickerTextField. diff --git a/NKVPhonePicker.xcodeproj/project.pbxproj b/NKVPhonePicker.xcodeproj/project.pbxproj index 2749d84..8f8d3a5 100644 --- a/NKVPhonePicker.xcodeproj/project.pbxproj +++ b/NKVPhonePicker.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ EB1D35E62045F3B900DC9560 /* NKVPhonePickerPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB1D35E52045F3B900DC9560 /* NKVPhonePickerPresenter.swift */; }; EB1D35E82045F74400DC9560 /* CountryCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB1D35E72045F74400DC9560 /* CountryCode.swift */; }; EB1D35EA2045F76C00DC9560 /* PhoneExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB1D35E92045F76C00DC9560 /* PhoneExtension.swift */; }; + EB1D35F520481B4E00DC9560 /* NKVSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB1D35F420481B4E00DC9560 /* NKVSource.swift */; }; EB50FA291ED8506700722C25 /* Countries.bundle in Resources */ = {isa = PBXBuildFile; fileRef = EB50FA271ED8506700722C25 /* Countries.bundle */; }; EB50FA2A1ED8506700722C25 /* CountriesViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EB50FA281ED8506700722C25 /* CountriesViewController.storyboard */; }; EB5621461F50B3B100398954 /* TextFieldWithPattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB5621451F50B3B100398954 /* TextFieldWithPattern.swift */; }; @@ -31,6 +32,7 @@ EB1D35E52045F3B900DC9560 /* NKVPhonePickerPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NKVPhonePickerPresenter.swift; sourceTree = "<group>"; }; EB1D35E72045F74400DC9560 /* CountryCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryCode.swift; sourceTree = "<group>"; }; EB1D35E92045F76C00DC9560 /* PhoneExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhoneExtension.swift; sourceTree = "<group>"; }; + EB1D35F420481B4E00DC9560 /* NKVSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NKVSource.swift; sourceTree = "<group>"; }; EB50FA271ED8506700722C25 /* Countries.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Countries.bundle; path = Bundle/Countries.bundle; sourceTree = "<group>"; }; EB50FA281ED8506700722C25 /* CountriesViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = CountriesViewController.storyboard; path = Bundle/CountriesViewController.storyboard; sourceTree = "<group>"; }; EB5621451F50B3B100398954 /* TextFieldWithPattern.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldWithPattern.swift; sourceTree = "<group>"; }; @@ -130,6 +132,7 @@ EB84919D1ED435AB0069CD20 /* Country.swift */, EB1D35E72045F74400DC9560 /* CountryCode.swift */, EB1D35E92045F76C00DC9560 /* PhoneExtension.swift */, + EB1D35F420481B4E00DC9560 /* NKVSource.swift */, ); path = Models; sourceTree = "<group>"; @@ -236,6 +239,7 @@ EB8491E71ED4370E0069CD20 /* NKVPhonePickerTextField.swift in Sources */, EB8491B01ED435AB0069CD20 /* CountriesViewController.swift in Sources */, EB5621461F50B3B100398954 /* TextFieldWithPattern.swift in Sources */, + EB1D35F520481B4E00DC9560 /* NKVSource.swift in Sources */, EB8491371ED435260069CD20 /* ExampleViewController.swift in Sources */, EBD53F561ED6E64F007510E3 /* NKVPhoneFormatter.swift in Sources */, EB1D35E62045F3B900DC9560 /* NKVPhonePickerPresenter.swift in Sources */, diff --git a/README.md b/README.md index 3ac6467..b581e97 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@   - +   diff --git a/Sources/Helpers/NKVSourcesHelper.swift b/Sources/Helpers/NKVSourcesHelper.swift index 64a8583..8c8978f 100644 --- a/Sources/Helpers/NKVSourcesHelper.swift +++ b/Sources/Helpers/NKVSourcesHelper.swift @@ -7,24 +7,6 @@ import UIKit -public enum NKVSource { - case country(Country) - case code(CountryCode) - case phoneExtension(PhoneExtension) - - init(country: Country) { - self = .country(country) - } - - init(countryCode: String) { - self = .code(CountryCode(countryCode)) - } - - init(phoneExtension: String) { - self = .phoneExtension(PhoneExtension(phoneExtension)) - } -} - struct NKVSourcesHelper { /// Gives the flag image, if it exists in bundle. diff --git a/Sources/Main/NKVPhonePickerTextField.swift b/Sources/Main/NKVPhonePickerTextField.swift index 43ef723..803d71b 100644 --- a/Sources/Main/NKVPhonePickerTextField.swift +++ b/Sources/Main/NKVPhonePickerTextField.swift @@ -123,7 +123,7 @@ open class NKVPhonePickerTextField: TextFieldPatternFormat { super.init(frame: CGRect.zero) } - override init(frame: CGRect) { + override public init(frame: CGRect) { super.init(frame: frame) initialize() } diff --git a/Sources/Models/Country.swift b/Sources/Models/Country.swift index 3793cf3..72ccd79 100755 --- a/Sources/Models/Country.swift +++ b/Sources/Models/Country.swift @@ -8,12 +8,12 @@ import Foundation import UIKit -public class Country: NSObject { +open class Country: NSObject { // MARK: - Properties /// Ex: "RU" - public var countryCode: String + @objc public var countryCode: String /// Ex: "7" @objc public var phoneExtension: String /// Ex: "Russia" @@ -21,7 +21,7 @@ public class Country: NSObject { return NKVLocalizationHelper.countryName(by: countryCode) ?? "" } /// Ex: "### ## ######" - public var formatPattern: String + @objc public var formatPattern: String /// A flag image for this country. May be nil. public var flag: UIImage? { return NKVSourcesHelper.flag(for: NKVSource(country: self)) diff --git a/Sources/Models/CountryCode.swift b/Sources/Models/CountryCode.swift index 5a72dea..bebee85 100644 --- a/Sources/Models/CountryCode.swift +++ b/Sources/Models/CountryCode.swift @@ -7,9 +7,9 @@ // public struct CountryCode { - var code: String + public var code: String - init?(_ source: NKVSource) { + public init?(_ source: NKVSource) { switch source { case .country(let country): self.code = country.countryCode @@ -24,7 +24,7 @@ public struct CountryCode { } } - init(_ countryCode: String) { + public init(_ countryCode: String) { self.code = countryCode } } diff --git a/Sources/Models/NKVSource.swift b/Sources/Models/NKVSource.swift new file mode 100644 index 0000000..73336be --- /dev/null +++ b/Sources/Models/NKVSource.swift @@ -0,0 +1,25 @@ +// +// NKVSource.swift +// NKVPhonePicker +// +// Created by Nik Kov on 01.03.18. +// Copyright © 2018 nik.kov. All rights reserved. +// + +public enum NKVSource { + case country(Country) + case code(CountryCode) + case phoneExtension(PhoneExtension) + + public init(country: Country) { + self = .country(country) + } + + public init(countryCode: String) { + self = .code(CountryCode(countryCode)) + } + + public init(phoneExtension: String) { + self = .phoneExtension(PhoneExtension(phoneExtension)) + } +} diff --git a/Sources/Models/PhoneExtension.swift b/Sources/Models/PhoneExtension.swift index 84dc302..4f11b8c 100644 --- a/Sources/Models/PhoneExtension.swift +++ b/Sources/Models/PhoneExtension.swift @@ -7,9 +7,9 @@ // public struct PhoneExtension { - var phoneExtension: String + public var phoneExtension: String - init?(source: NKVSource) { + public init?(source: NKVSource) { switch source { case .country(let country): self.phoneExtension = country.phoneExtension @@ -24,7 +24,7 @@ public struct PhoneExtension { } } - init(_ phoneExtension: String) { + public init(_ phoneExtension: String) { self.phoneExtension = phoneExtension } }