Search code examples
iosvalidationemailnspredicatensregularexpression

Email Validation in iOS


Email validation checking in iPhone programming can be done using RegexKitLite library (iOS2.0), NSPredicate (iOS 3.0 onwards) and NSRegularExpression (iOS 4.0). But can anybody state what is the advantage of one over the other and which is the best validating option of the three stated.


Solution

  • I think it largely depends on the minimum version of iOS an App will support, and if there's a built-in class that'll do the job, use it. As you hinted, you'd use some other 3rd-party framework to support older versions in a consistent way.

    Right now, I'd use NSPredicate or NSRegularExpression, both are supported from iOS 4 onwards, which is quite likely to be the minimum supported version for new iOS Apps, if not iOS 5.

    Useful post.