Note that there are some explanatory texts on larger screens.

plurals
  1. POStoryboard & Segue - Passing datas am i doing it good?
    text
    copied!<p>I'm using Storyboards &amp; segues. I want to switch from "Contacts List" (tableView) to a "Profile view" (ScrollView).</p> <p><strong>Three questions</strong> : </p> <ul> <li>Is this the best way (more clean &amp; beautiful) to do this ? <strong>&amp; Why ?</strong></li> <li>When i do this : ProfileViewController *aProfileView = (ProfileViewController *)[segue destinationViewController]; is this instantiate a new view ? (Like it will create 2 Profile view).</li> <li>do i need to clean (delete the "Profile View" somewhere ?) or it's doing it alone with the Navigation controller ?</li> </ul> <p>// Code</p> <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"showProfileSelected"]) { // Get the Selected raw NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; Profile *selectedProfile = [self.profilesTable objectAtIndex:indexPath.row]; // Using segue --&gt; Send the current selected profile to "ProfileView" ProfileViewController *aProfileView = (ProfileViewController *)[segue destinationViewController]; aProfileView.currentProfile = selectedProfile; } } </code></pre> <p>// Other way to do this :</p> <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"showProfileSelected"]) { // Get the Selected raw NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; Profile *selectedProfile = [self.profilesTable objectAtIndex:indexPath.row]; // Using segue --&gt; Send the current selected profile to "ProfileView" [segue.destinationViewController setCurrentProfile:selectedProfile]; } } </code></pre>
 

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