Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Custom Check For iPhone , IOS Version , Email And Phone Number in swift

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.35k
    Comment on it

    Hello Readers,

    These are some of the custom checkers to detect

    • iPhone
    • Current IOS Version
    • Email Validation
    • Phone Number Validation

    For iPhone 4 and 4s :-

    func isIPHONE4() -> Bool{
            let screenSize: CGRect = UIScreen.mainScreen().nativeBounds
            return screenSize.height == 960 ?true:false
        }
    

    For iPhone 5 , 5c and 5s :-

    func isIPHONE5() -> Bool{
            let screenSize: CGRect = UIScreen.mainScreen().nativeBounds
            return screenSize.height == 1136 ?true:false
        }
    

    For iPhone 6 :-

    func isIPHONE6() -> Bool{
            let screenSize: CGRect = UIScreen.mainScreen().nativeBounds
            return screenSize.height == 1334 ?true:false
        }
    

    For iPhone 6+ :-

    func isIPHONE6Plus() -> Bool{
            let screenSize: CGRect = UIScreen.mainScreen().nativeBounds
            return screenSize.height == 2208 ?true:false
        }
    

    For IOS Version :-

    func getCurrentOS() -> NSString{
            return UIDevice.currentDevice().systemVersion
        }
    

    For Email Validation :-

    func isValidEmail(testStr:String) -> Bool {
            // println("validate calendar: \(testStr)")
            let emailRegEx = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"
    
            let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
            return emailTest.evaluateWithObject(testStr)
        }
    

    *For Phone Number Validation :- *

    func isPhoneNumbervalidate(value: String) -> Bool {
            let PHONE_REGEX = "^((\\+)|(00))[0-9]{6,14}$"
            var phoneTest = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX)
            var result =  phoneTest.evaluateWithObject(value)
            return result
        }
    

    For iPad

    func isIPAD() -> Bool{
            return UIDevice.currentDevice().userInterfaceIdiom == .Pad ?true:false
        }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: