ios - ViewControllers are not destructing -


i've got serious problem ios app.

i have login logic in application. when logging in , logging out, view controllers not destructing. causes issues, example, events emit using nsnotifcationcenter emitted few times. these issues avoidable, want solution avoid view controllers stay open in background without me controlling it.

the way control login logic follows:

in app delegate start function, if user logged in, set root view controller main usable view controller. therefore, i'm not doing , root view controller set login view controller navigation controller through storyboard.

when user logs off, use modal segue transition view controller login view controller navigation controller.

as may understand i'm using storyboards, swift , newest ios.

my logout code segue take me loginviewcontroler:

self.performseguewithidentifier("logout", sender: self) 

my app delegate code:

if (userdefaults.valueforkey("uid") != nil) {     let tabbarview = uistoryboard(name: "main", bundle: nil).instantiateviewcontrollerwithidentifier("tabbarviewcontroller") as! tabbarviewcontroller     let appdelegate = uiapplication.sharedapplication().delegate as! appdelegate     appdelegate.window?.rootviewcontroller = tabbarview          } 

what doing wrong?

i appreciate :)

edit

i tried setting root view controller in logout action , didn’t either. how’s possible?

this how logout now:

let appdelegate = uiapplication.sharedapplication().delegate as! appdelegate let newrootviewcontroller = self.storyboard?.instantiateviewcontrollerwithidentifier("loginnavigationcontroller") as! uinavigationcontroller            appdelegate.window!.rootviewcontroller = newrootviewcontroller 

if logged in screen presents login screen , login screen presents logged in screen have cycle keeps piling on new view controllers. solve this, 1 must not present other, unwind it. possibility hold instances of each singletons , present those.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -