• Neno83

    Hello

    You said in video 2 you will create a video showing hot to avoid the shortly appearing of the protected page before login.

    How to do that?

    Thank you very much
    Best regards

  • sephethus

    What if the user has just installed the app and the boolForKey isn’t created yet? Then there is no bool to determine whether they are logged in.

    • Then, initial ViewController should launch.

      • sephethus

        Figured out the default bool for a key that isn’t created yet is false, so the login launches.

        • iKhalil

          Use

          //Initializing defaults

          NSUserDefaults.standardUserDefaults().registerDefaults(
          [
          “IsUserLoggedIn” : false,
          ])

          in your AppDelegate.swift file 😉

  • Chris Brown

    Hi, thanks for a great tutorial, it works great. Just wondered if you could help with this question:- I want to have 2 buttons on the protected page which are both disabled by default and then when the user has logged in ( a boolean value is retrieved from database) and we dismiss the login view controller, one of the buttons on the protected page is enabled dependent on the boolean value. How would I pass this value back to the protected page? Thanks, any help you can give is greatly appreciated

    • You can declare a property(variable) in your protected page. And then set this variable from the login view just before you are taking user to protected page. For example:

      let protectedPage = self.storyboard?.instantiateViewControllerWithIdentifier(“ProtectedPageViewController”) as! ProtectedPageViewController

      protectedPage.myBoolVar = true;

      let protectedPageNav = UINavigationController(rootViewController: protectedPage)

      let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate

      appDelegate.window?.rootViewController = protectedPageNav

      • Chris Brown

        Thank you, I shall give it a try :-))

  • Nathan Berhe

    Hey sergey, how do i change the initial viewcontroller programmatically if the user for example log in, i want the next view to always load up first and if user log out i want the login viewcontroller to load up first?

  • Lyheang IBell

    var error:NSError?
    var json = NSJSONSerialization.JSONObjectWithData(data, optionsns:.MutableContainers, error: &error) as NSDictionary

    I got message error: => error: &error I used swift 2+ and IOS 9+ please help me fix this