1
votes

I have a Page View Controller as an introduction tutorial off to the side. My Login/SignUp VC's segue to the Tab Bar Controller. Which is my home.

Here's what I am trying to accomplish:

  1. If it's the users first time launching the app, go to the Page View Introduction which leads them to the Login/SignUp.

  2. If the user has logged in before, then go to the home screen of the tab bar controller.

My Login/SignUp view controllers are the set to the initial view controllers. (I use Parse if that matters). I'm guessing I should set the Page View introduction tutorial as the initial view controller? I can link the Login/SignUp VC's to the Page View but don't really know where to go from there. All the answers I've found have been in Objective C, which doesn't help.. Thanks!

1
Check this repository it may help. github.com/jasonnam/InAndOut-iOS-DemoJason Nam

1 Answers

3
votes

What you want is called NSUserDefaults, you can read about it here:

It works as a key-value mechanism that will store data in your app. When you finish launching the app (applicationDidFinishLaunchingWithOptions in app delegate) you can do something like this:

let defaults = NSUserDefaults.standardUserDefaults()
if defaults.objectForKey("userAsLoggedInBefore") {

    //here you insert the code to go to the home screen

} else {

    //this means the user hasn't logged in before and you can redirect him to the registeration page

} 

To set the "User Logged In Information", you just have to put the following code when you want it to happen (in this case after the first sucessfull login)

NSUserDefaults.standardUserDefaults().setObject("1", forKey: "userAsLoggedInBefore")

If you need any more help, just say and I'll try to help you.