Passing data from one UIViewController to another

In an MVC framework Views are visual representations of the Model. Strictly speaking you shouldn’t want to pass information from a current UIViewController to another one about to be navigated to as the Model should contain what any View should need but in practice this is a very useful thing to be able to do.

When developing for the Android platform this ability is provided by Intents and when using the SimpleIOSViewStack using a View Dictionary.

Two steps are required to get this to work :
  1. The target UIViewController has to be a SimpleIOSViewStackDelegate.
  2. Provide an NSDictionary to SimpleIOSViewStackNotificationVO when posting the notification.
SimpleIOSViewStackDelegate ensures that a viewDictionary public property is defined on the target UIViewController. This is set just before the UIViewController is added / re-added or in the case of recycling a target and disposing of the current (and all in between) just before the removing happens.

The easiest way to handle this data is to define a setter for viewDictionary on the target UIViewController.

[[NSNotificationCenter defaultCenter]

                      object:[[SimpleIOSViewStackNotificationVO alloc]
                           dictionaryForView:@{@"property" : @"value"}

and then in the target :

 -(void)setViewDictionary:(NSDictionary *)value{
    NSLog(@"%@" , value);