Simple phone number validation in swift ios 8 , Using this function you can easily check phone number . Also have some example for this using NSPredicate etc .
you can see lots of method for number validation. But I made this sort method
func phoneNumberValidation(value: String) -> Bool {var charcter = NSCharacterSet(charactersInString: "0123456789").invertedSetvar filtered:NSString!var inputString:NSArray = value.componentsSeparatedByCharactersInSet(charcter)filtered = inputString.componentsJoinedByString("")return value == filtered}
How to use this validation function in code
if self.phoneNumberValidation(contactNumTextF.text) == false {let alert = UIAlertView()alert.title = "Message"alert.message = "Enter Valid Contact Number"alert.addButtonWithTitle("Ok")alert.delegate = selfalert.show()
// Number valid}else {
}
You can also check this validation in Objective C Language simple phone number validation in IPhone sdk Objective C
Thanks for Visit , Also can visit on My blog Facebook page iPhone & iPad Application Development Help World and also can visit Google+