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 to serve their

This is what makes Laravel the best PHP framework

Laravel, with its clean and robust output, has rapidly become the most preferred PHP framework. The coding ease it offers along with the security features it carries has made it the most admired PHP framework on GitHub. But when you set out to hire Laravel developers , you must know everything that makes Laravel special. Knowing the strengths of Laravel will be one of the surest ways of getting something truly remarkable from Laravel. In the world of PHP development, you have some awesome options like Yii2, Symfony, CodeIgniter or Zend, here’s top 6 things that makes Laravel stand apart. 1. The MVC feature A web application has two faces: the logic code face and the aesthetic, user-friendly presentation face. It is important the two remain separate. Why? That’s because occasionally, you’ll want to change the looks of the web page. If you get the developer involved in such design alterations every time, you’re blocking the developer resources (which are generally considered mo

How To Start An Online Grocery Store

If you are thinking of starting an online grocery store….. ….there’s this vital bit of statistics: Accenture estimates that by 2020, out of the total retail consumption by shoppers worldwide, eCommerce will get 13.5%. In other words, out of every 7 dollars spent on retail consumption, eCommerce will get a little over 1 dollar. Gold rush. Isn’t it ? Add to it the fact that there’s practically no way you don’t buy grocery – whatever the channel of purchase – you have a promising grocery market. And yet, people planning to get into the business of online grocery store often think the market is the same as that of an e-retailers…. …….That’s incorrect. Beyond some superficial similarities the two businesses share, at an operational level, they are entirely different. For instance, an online grocery store deals with items that are perishable in nature, unlike an e-retailer who faces no such risks.  As a result, when you are trying to figure out how to start an online grocer