Skip to main content

How to check email is valid or not

Most of the mobile applications use the email for login or other purpose. So we need to

validate email if it contains the valid email string. We can achieve it by using

NSPredicate.

1. Add following method

1. -(BOOL)isValidEmail:(NSString *)checkString

2. {

3. long numberOfAtPieces = [[checkString componentsSeparatedByString:@"@"]

count];

4.

5. if (numberOfAtPieces > 2){

6. return NO;

7. }

8.

9. BOOL stricterFilter = NO;

10. NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-
z]{2,4}";

11. NSString *laxString = @".+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*";

12. NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;

13. NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES

%@", emailRegex];

14. return [emailTest evaluateWithObject:checkString];

15. }

2. Call this method and pass string containing email to it like below

BOOL isValid = [Self isValidEmail:@”sample@email.com”];

If email is valid then isValid value is TRUE else value is FALSE.

 If you have any further doubts, drop us an email at info@infigic.com and we’ll get back to you with the best possible solution. Infigic is a Mobile Application Development Company and we are always there to solve your queries

Comments

Popular posts from this blog

The Best Pharmacy Apps for 2019

When you can buy almost everything online, there’s no reason why you can’t buy medicines online. The steady growth in the number of apps to purchase medicine online shows how online businesses are adding convenience and comfort in one more area. And the growth is not surprising, considering that  the US spent over $450 billion on medicines in 2016 . Even a small piece of the pie in the business to serve customers who buy medicine online is big business. A pharmacy delivery app brings a number of benefits to everyone, from pharmacies to patients. Some benefits like ease of purchase or competitively priced products are quite obvious. However, these apps are capable of adding a lot of value to users. From helping people fix consultation appointments to publishing health blogs, these apps are offering an almost 360-degree service that physical visits to local pharmacies cannot. Little wonder that most  physical retail pharmacies  are adding mobile apps with which t...

7 Things to Consider Before Hiring Laravel Developers

Laravel is a well known PHP net framework that's gaining popularity with every passing day. It is preferred by plenty of significant web developing industries because of its simple and convenient use. Laravel was introduced in the year 2011 and now in 2017 it has developed itself to be the very appreciated PHP framework, that's utilized by different industries for their web development jobs. It is capable of managing various projects ranging from a simple web app to difficult APIs. Prior to getting into a detailed discussion on Laravel developer let's take a look at the critical features of Laravel frame. 1)  Easy to combine with other programmes 2)  Excellent resources 3)  Easy authentication 4)   Multiple file system 5)   Route caching 6)  Highly tested HTTP coating 7)  Powerful unit testing 8)   Energetic record execution etc.. Because of all of these features, presently Laravel is in high demand as well ...

Wordpress to Laravel

Overview Client has decided to switch his business website from Wordpress to Laravel or similar PHP framework. Client wants to have latest technology services associate with his business website. Challenge Challenge faced while development was incorporating forum, blogs, job board and online Store in single website. Definitely it was a switch from Wordpress to Laravel that took some time to understand old one and transform it to new one. Client also required an admin panel to customize things on his own website. Result Infigic understood the requirements thoroughly. Infigic developed a Laravel based website. Website has a forum for various discussions to takes place among the users. There is a job board which notify you about various jobs for you to take part. Client  liked the new look and interface of  Laravel Website. Features: Forum Blog with articles Job Board Listings ( For Health Professionals) Basic Online Store Basic Admin Pa...