先在appdelegate 裡面的內容
這裡是確認下次跳轉會直接跳過登入介面
if NSUserDefaults.standardUserDefaults().boolForKey("isok"){
let logon = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("tabbarVC")
self.window?.rootViewController = logon
}
else if NSUserDefaults.standardUserDefaults().boolForKey("isOpen"){
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "isok")
let logon = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("logon")
self.window?.rootViewController = logon
}
然後是一個輕量級的資料的儲存
只有登入了才可以儲存
self.vie.removeFromSuperview()
let logon = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("tabbarVC")
tickets = "\(keyy)" + "," + "\(rod)"
NSUserDefaults.standardUserDefaults().setObject(tickets, forKey: "ticket")
self.presentViewController(logon, animated: true, completion: nil)
}
傳值到紅產量上
tickets = NSUserDefaults.standardUserDefaults().objectForKey("ticket") as! String
退出登入清空本地內容,再進去登入介面
NSUserDefaults.standardUserDefaults().removeObjectForKey("ticket")
let logon = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("logon")
self.view.window?.rootViewController = logon
self.presentViewController(logon, animated: true, completion: nil)