Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>clankill3r,</p> <p>You should avoid creating singleton <code>UIViewController</code>s (see comments in this discussion <a href="https://stackoverflow.com/questions/5781749/uiviewcontroller-as-a-singleton">UIViewController as a singleton</a>). This has been also highlighted by <strong>@CarlVeazey</strong>.</p> <p>IMHO, you should create a <code>UIViewController</code> each time you need it. In this case your view controller would be a reusable component. When you create a <strong>new</strong> instance of your controller, just inject (though a property or in the initializer the data you are interested in, <code>suggestedRoute</code> in this case).</p> <p>A simple example could be the following:</p> <pre><code>// YourViewController.h - (id)initWithSuggestedRoute:(id)theSuggestedRoute; // YourViewController.m - (id)initWithSuggestedRoute:(id)theSuggestedRoute { self = [super initWithNibName:@"YourViewController" bundle:nil]; if (self) { // set the internal suggested route, e.g. _suggestedRoute = theSuggestedRoute; // without ARC enabled _suggestedRoute = [theSuggestedRoute retain]; } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self drawSuggestedRoute:[self suggestedRoute]]; } </code></pre> <p>For further info about <code>UIViewController</code>s, I really advice to read two interesting post by <strong>@Ole Begemann</strong>.</p> <ul> <li><a href="http://oleb.net/blog/2012/02/passing-data-between-view-controllers/" rel="nofollow noreferrer">Passing Data Between View Controllers</a></li> <li><a href="http://oleb.net/blog/2012/01/initWithNibName-bundle-breaks-encapsulation/" rel="nofollow noreferrer">initWithNibName:bundle: Breaks Encapsulation</a></li> </ul> <p>Hope that helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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