Tagged with:  

138 Responses to “iOS Login and Signup Screen tutorial : Swift + XCode 6 + iOS 8 + JSON”

  1. wu says:

    Many thanks for this excellent tutorial.

  2. Herolee says:

    Hello Dipin,
    I can not login on our site wordpress also PHP.
    Please help,

  3. Rob Dingwall says:

    Hi Dipin,
    Many thanks for this excellent tutorial.
    Is it possible to update it for Xcode version 7.3.1?

  4. erhan says:

    thank you

  5. Alam Usmani says:

    Thanks a lot your post help me very much, i am recently switch to iOS from dot net.

  6. Christian says:

    I have one more column named email, how can i show user’s email when user login? And how to store all user’s information to NSUserDefaults with email, firstname, lastname, age…

    • You need to pass the info you need in the JSON reply during login.
      Then parse the json and save it in the NSUserDefaults.


      var firstname:NSString = jsonData["firstname"] as NSString
      var lastname:NSString = jsonData["lastname"] as NSString
      var prefs:NSUserDefaults = NSUserDefaults.standardUserDefaults()
      prefs.setObject(username, forKey: "USERNAME")
      prefs.setObject(firstname, forKey: "FNAME")
      prefs.setObject(lastname, forKey: "LNAME")
      prefs.setInteger(1, forKey: "ISLOGGEDIN")

      Hope it helps!

      • Christian says:

        i got an error when i tried to log in
        fatal error: unexpectedly found nil while unwrapping an Optional value
        xcode show green line at: var lastname:NSString = jsonData[“email”] as! NSString

      • Check if the value exist:

        var email:NSString
        if((jsonData["email"]) != nil) {
            email = jsonData["email"] as! NSString
  7. James says:

    I keep getting this error: fatal error: “unexpectedly found nil while unwrapping an Optional value”

    It is on this line of the code:

    “let jsonData:NSDictionary = NSJSONSerialization.JSONObjectWithData(urlData!, options:NSJSONReadingOptions.MutableContainers , error: &error) as! NSDictionary”

Leave a Reply