Take the 2-minute tour ×

The best answer on stackoverflow for pushing an array to a tableView cell is "start with something easier". I think we can do better than that...

I believe I have everything in place except I can not find the proper way to address getting the data from the rootView. See Below.

The below code pushes an array to DetailView Controller with three cells in a group with "Get Cell Info Here" in top cell. Can someone explain what I need to do to get the actual data into the top cell? Thanks


    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    DetailViewController *selectedCell = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
    [self.navigationController pushViewController:selectedCell animated:YES];



@interface DetailViewController : UITableViewController {

    NSArray *displayCell;



- (void)viewWillAppear:(BOOL)animated

    //Display the selected cell data

    displayCell = [[NSArray alloc] initWithObjects:@"Get Cell Info Here", nil];  

    //Set the title of the navigation bar
    self.navigationItem.title = @"wtf";


    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] ;

    // Make cell unselectable
    cell.selectionStyle = UITableViewCellSelectionStyleNone; 

    NSString *cellText = nil;

    switch ( indexPath.row ) {
        case 0: {
            cellText = [displayCell objectAtIndex:indexPath.row]; 

            break ;
        case 1: {

            break ; 
        case 2: {

            break ;

        cell.textLabel.text = cellText;
        return cell;

share|improve this question
i think you want to pass the array of RootViewController to DetailView ,am i right?? –  Paras Joshi May 29 '12 at 18:25
Are you trying to send your array to a detail view? Clarify. It sounds to me like you have a table view that you want to populate from an array and send the actual array when clicked to it's detail view. Clarify for us. –  erran May 29 '12 at 18:32
Wow that was fast... yeah, i didn't get into the data... I have three pieces of info, Title, Detail, Picture. They all show in the array, now I'm trying to get them to show in one cell in the DetailViewController, but this time it will show the Full detail instead of just 2 lines and a truncated tail. –  user1424344 May 29 '12 at 18:38
Every "Detail View Controller" tutorial i have seen is about pushing to a white screen and using a UILabel to display the array data. I'm looking to display the array data in a larger cell (which I have already customized). It's basically to keep the "Grouped look" on every view, like (who else but) Twitter. –  user1424344 May 29 '12 at 19:26

1 Answer 1

Add a property to DetailViewController as follows:

@property (nonatomic, retain) NSArray *passedItems;

Then have root view controller pass the items as follows:

selectedCell.passedItems = passedItems; // passedItems is array in rootview controller

Then you can use passedItems in DetailedViewController.

share|improve this answer
Ok, now where does ( selectedCell.passedItems = passedItems; ) go? In didSelectRow..? How? –  user1424344 May 29 '12 at 23:32
I only used "selectedCell" to push a view in didSelectRowAtIndexPath. To display the Array in the RootView I use "cellArray". This is where I am missing the connection from the RootView data to the DetailView data. I appreciate your help so far @jamihash –  user1424344 May 29 '12 at 23:48
It would go right after you create DetailedViewController in the didSelect method. passedItems should contain all the items needed by DetailedViewController to display its table cells. –  jamihash May 30 '12 at 0:10
Great that's easy but this is where the connection is lost... how do I reference the array data so it shows in the next view? Do you have any example code? I can not find any examples of this in apple's docs. DetailViewController *selectedCell = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped]; selectedCell.passedItems = cellArray; //do i need to reference every piece of data here? The "title" "details" "photo" "etc"? This is the primary piece I do not understand. [self.navigationController pushViewController:selectedEvent animated:YES]; –  user1424344 May 30 '12 at 1:56

Your Answer


