UrbanPro
true

Learn iOS Developer from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Phone number validation in swift language

Naga Kranthi
23/05/2017 0 0

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”).invertedSet
var 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 = self
alert.show()
}else {
// Number valid?         }

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Working With Arrays in Swift
Swift Arrays:Like Objective C arrays Swift arrays are also collection of Objects The Difference is in swift we don't work directly with addresses.The declaration of Swift array is as follows The above...

10 Ways My Life Changed When I Learned To Code
1. I have freedom to make my own schedule. 2. I earn more, but work fewer hours. 3. I can say “no” to job offers. 4. People come to me asking if I can work for them. 5. I never have to...

Developing iOS Apps Part 1
The Basics Swift opts to use a Javascript-like ‘var’ keyword to define any new variable. So for example to create a new variable with a bit of text in it, you would have this: var...

P Balasubramanyam

0 0
0

IOS App Development
Student could work on the normal laptop or system. Some of student are thinking that Mac operating system is mandatory for Learn IOS but this is not mandatory. Thanks Ajay

On the Job training is always best
On the job training always provides an opportunity to learn the best industry practices. While you work on real time you would encounter many challenges that will force you to learn many new things. Class...
M
X

Looking for iOS Developer Classes?

The best tutors for iOS Developer Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn iOS Developer with the Best Tutors

The best Tutors for iOS Developer Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more