In the Utility Template, the MainViewController
(the view controller for the front side) creates the FlipsideViewController
(the view controller for the back side) in the showInfo:
method. You can pass whatever data you like to the FlipsideViewContrller
constructor (provided, of course, that you change the constructor to accept the data).
Alternatively, you could define some properties in FlipsideViewController
. After you create the object (again in showInfo:
) you can then set those properties with the data you want to pass.
Edited per @Sam's comment:
In FlipsideViewController.h
, you'd define a property to hold the data you want to show. Here, I'm making it an NSString
but it can be anything.
@property (nonatomic, retain) NSString *someDataToShow;
In MainViewController.m
, after you create the FlipsideViewController
, you'd set the property. Note, this assumes you have a method computeDataToPassToFlipside
defined in MainViewController
that returns an NSString
.
- (IBAction)showInfo:(id)sender
{
FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
controller.delegate = self;
controller.someDataToShow = [self computeDataToPassToFlipside];
// ...
}
Finally, in FlipsideViewController.m
you need to do something with the data you have passed to the property. So, for example, let's say you have a UILabel
called myLabel
that you want to have display the NSString
property. I'm going to assume the UILabel is correctly included and attached to an IBOutlet
using Interface Builder.
- (void)viewWillAppear:(BOOL)animated
{
myLabel.text = self.someDataToShow;
}