Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing Data between View Controllers : from uitableview to a details view controller
    primarykey
    data
    text
    <p>I am using IOS 5 and Storyboard coding. I have built an application in which i have a tableView connected to a sqlite database with a search bar. When we touch a row, it will take us automatically to another view controller called "Details". I need to pass data from my table view to the details view controller, pass for example the author.title to the labelText.text field. Any ideas?</p> <p>Edited question:</p> <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ // NSString *Title; Details *dv = (Details*)segue.destinationViewController; author.title = dv.labelText.text; } </code></pre> <p>Partial code:</p> <pre><code>// // Details.m // AuthorsApp // // Created by georges ouyoun on 7/17/12. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // #import "Details.h" #import "Author.h" @interface Details () @end @implementation Details @synthesize labelText; @synthesize selectedAuthors; @synthesize author; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.labelText.text = self.author.title; // Do any additional setup after loading the view. NSLog(@"Everything is ok now !"); } - (void)viewDidUnload { // [self setLabelText:nil]; NSLog(@"U have entered view did unload"); [super viewDidUnload]; [self setLabelText:Nil]; // Release any retained subviews of the main view. } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ // NSString *Title; Details *dv = (Details*)segue.destinationViewController; // author.title = dv.labelText.text; dv.labelText.text = author.title; } /* - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ if ([segue.identifier isEqualToString:@"AuthorsCell"]) { [segue.destinationViewController setLabelText:author.title]; } } /* -(void)viewWillAppear:(BOOL)animated { self.labelText.text = author.title; NSLog(@"U have entered the viewWillAppear tag"); // detailsLabel.text = food.description; } */ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } - (void)dealloc { [labelText release]; [super dealloc]; } @end </code></pre>
    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.
 

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