ios - Call a segue in another class that the UI with swift -


I'm rapidly creating an iOS app. I have a UIViewController and a "UserManager" class that comes from NSObject . Basically, when the user opens the app, the UIViewController is executed within the code. UIViewController calls a function in UserManager when this function is finished, so I want to have a SEGU (a SEGU called "Connect SEJU" in my code). I'm starting a ...

What I did (and did not work!):

Here's my view controller:

  Import UIKit var profileUser = UserManager () Class view controller: UIViewController {override func viewDidLoad () {login ()} func login () - & gt; Zero {profileUser.createUser ()} func handleSegue () - & gt; Zero {self.performSegueWithIdentifier ("ConnectSegue", sender: self)}}  

Here is my User Manager class:

  Import Foundation class UserManager: NSObject {// some properties () - & gt; Zero {// some code var seguelihoodler = view controller () segueHandler.handleSegue ()}}  

How can I do this? Thank you

The problem is that your Userman is creating a new instance of the View Controller, which is not the one That's called UserManager.

There is a better way to handle it, after logging in, to call performSegueWithIdentifier in your View Controller.

In general, you do not insert UI navigation inside non-UI classes. User Manager will be more useful if this user functions only, not UI responsibilities. If the user manager is doing his job asynchronously, you should consider working your view controller back using the notification, when it is completed, it can lead to seguation.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -