Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8090769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:49:52+00:00 2026-06-05T19:49:52+00:00

Possible Duplicate: Check that an email address is valid on iOS What is the

  • 0

Possible Duplicate:
Check that an email address is valid on iOS

What is the regex syntax I can use for email validation in iOS for my UITextField.text value? And is there a way for me to check if other UITextField or UITextView is missing?

Can I use this to test for blank values:

if(content.text == nil){
    //do something
}
else{
    //proceed with next course of action
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:49:53+00:00Added an answer on June 5, 2026 at 7:49 pm

    To be absolutely sure that you have tested for a blank value, you should also test for an empty string.

    This construct does it, and leads to less typing than using isEqualToString:, but it is largely a question of personal preference:

    if ( content.text == nil || content.text.length == 0 ) {
    
    }
    

    People with a more intimate knowledge of the Objective-C runtime might point out that testing for nil is redundant, as sending a message to nil will always yield nil (or 0), so content.text.length is nil if content.text is. Also, if your surroundings are populated with hard-core C coders, they could similarly point out that testing for 0 in an if statement is for wimps.

    Hence, the typing can be reduced to the following, at the cost of some clarity of your code:

    if ( !content.text.length ) {
    
    }
    

    As for a regex to test an email address, there is a good discussion here, and the regex in Cocoa can be done like this:

    NSPredicate *regexPred = [NSPredicate predicateWithFormat: @"self matches[cd] '<email regex here>'"];
    BOOL match = [regexPred evaluateWithObject: content.text];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Email Address Validation for ASP.NET <input id=txtemail type=text /> private void btnDelete_Click(object
Possible Duplicate: How to check if an email address exists without sending an email?
Possible Duplicate: Create WPF TextBox that accepts only numbers How i can check if
Possible Duplicate: How to check iOS version? I'm building an app that has an
Possible Duplicate: Check iPhone iOS Version I am trying to setup some code that
Possible Duplicate: How to check if text is “empty” (spaces, tabs, newlines) in Python?
Possible Duplicate: How can you check for a #hash in a URL using JavaScript?
Possible Duplicate: How can I check if an ip is in a network in
Possible Duplicate: PHP: Check who had read sent email? I'm writing a tool in
Possible Duplicate: Check status of services that run in a remote computer using C#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.