Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The quote is at Introduction > Style:</p> <blockquote> <p>We will always create view controllers programmatically. Some programmers will instantiate view controllers inside XIB file. We've found this practice leads to projects that are difficult to comprehend and debug.</p> </blockquote> <p>They talk about instantiation. If you have two view controllers A,B, you can alloc/init B in A's implementation, or you can drop a reference to B in A's XIB. In both cases, B may be defined in a XIB or not (the Big Ranch book advises to use XIBs for complex view controllers btw).</p> <hr> <p>Anyway, here is the difference:</p> <pre><code>CitySelectionVC *citySel = [[[CitySelectionVC alloc] initWithCities:self.cities] autorelease]; [self.navigationController pushViewController:citySel animated:TRUE]; </code></pre> <p>vs</p> <pre><code>citySel.cities = self.cities; [self.navigationController pushViewController:citySel animated:TRUE]; </code></pre> <p>First case is a explicit instantiation in code. It tells me:</p> <ul> <li>The VC is created now.</li> <li>It needs the cities to work.</li> </ul> <p>The code in the second block references an outlet instantiated in the XIB. It tells me:</p> <ul> <li>A VC was instantiated at unknown time, with unknown requirements.</li> <li>I'm passing the cities.</li> </ul> <p>I favor the first style because it is more explicit, and gives me control of the lifespan of the object.</p> <p>In iOS 5 you can use Storyboards to create transitions and pass information between controllers. See Session 309 of WWDC2011.</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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