Skip to content

Commit

Permalink
Merge pull request #24 from JNDisrupter/development
Browse files Browse the repository at this point in the history
- Fix Bug in Parsing very very Long Phone Number
  • Loading branch information
jayelzaghmoutt authored Mar 10, 2020
2 parents 664d0e2 + 3ae3387 commit a755f61
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion JNPhoneNumberView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = "JNPhoneNumberView"
s.version = "1.0.12"
s.version = "1.0.13"
s.summary = "Phone Number Validation with country dial code picker"
s.description = "A view to show the country dial code and the phone number, you can click on the dial code and select another country from the countries picker, this view has a delegate methods to pass the international number and validity of it."
s.homepage = "https://github.com/JNDisrupter"
Expand Down
2 changes: 1 addition & 1 deletion JNPhoneNumberView/Classes/JNPhoneNumberView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public class JNPhoneNumberView: UIView, UITextFieldDelegate {
if let nationalNumber = Double(nationalNumber) {

// Check if number positive
if nationalNumber > 0 {
if nationalNumber >= 0 {
self.textField.text = Int(nationalNumber).description
} else {
self.textField.text = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,20 @@ import libPhoneNumber_iOS
// Check if national number not empty
if nationalNumber!.length > 0 {

// Convert national number from string to number
let nationalPhoneNumber = NSNumber(value: nationalNumber!.floatValue)
// Convert NSString To String
let stringNationalNumber: String = nationalNumber! as String

// National Phone Number
var nationalPhoneNumber: NSNumber

if let integerValue = Int64(stringNationalNumber) {
// Convert national number from string to NSNumber
nationalPhoneNumber = NSNumber(value: integerValue)
}else{
// Convert national number from NSString to NSNumber
nationalPhoneNumber = NSNumber(value: nationalNumber!.floatValue)
}


// set national number
nbPhoneNumber.nationalNumber = nationalPhoneNumber
Expand Down

0 comments on commit a755f61

Please sign in to comment.