Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to call multiple viewControllers one at a time via NSNotifications in iOS
    text
    copied!<p>I have an application that I am working on that has several viewControllers, with each one displaying a single test for the user to do. At the moment, the user is able to go through each one individually. However, I am trying to implement a wizard-like function where a user can select multiple tests, or all tests, and the application in turn will iterate through each test, presenting each screen to the user, and once the user has submitted input, the application will move to the next test sequentially. Once all the tests have completed, the user will be brought back to the main screen. From what I have read, NSNotifications would be the best way to do this, but I honestly am new to this and need help. I realize that I should have in the method that initiates the wizard the line:</p> <pre><code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(testChange:) name:@"Test" object:nil]; </code></pre> <p>I also know that once each viewController has finished running, it is to post a notification in the following way:</p> <pre><code>[[NSNotificationCenter defaultCenter] postNotificationName:@"Test" object:self]; </code></pre> <p>My question is, if I have ten or twenty viewControllers selected by the user from a table, and these selections are stored in an array, do I need to have as many calls to the addObserver method, and as many postNotifications? What I would like to do is simply go through each viewController (as selected by the user), and once the user has finished submitted input to that viewController, that viewController should send a message, and the user should move on to the next viewController, and after finishing all tests, return to the main screen. Just as an FYI, I need to call each ViewController's (viewDidLoad) method.</p> <p>I apologize if my question is confusing.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload