Question

I have a project I am working on and it requires drill down UITableView. i have adapted my code to storyboard and it drills down fine from the first UITableView to the second UITableView but when I select the rows in the second UITableView I only get one of the arrays. when selecting any other row it just shows the detail for one of the rows. i know the description is vague so I am including my codes for more clarification. any help is truly appreciated.

TeamTable.m

@implementation TeamTable

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];

    teamArray = [[NSMutableArray alloc] init];
    [teamArray addObject:@"East Cobb"];
    [teamArray addObject:@"West Cobb"];
    [teamArray addObject:@"Buckhead Thunder"];
    [teamArray addObject:@"Fulton East"];
    [teamArray addObject:@"Atlanta Braves"];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:  (UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [teamArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault     reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell...
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:cell.frame];
    UIImage *image = [UIImage imageNamed:@"bgp.png"];
    imageView.image = image;
    cell.backgroundView = imageView;
    [[cell textLabel] setBackgroundColor:[UIColor clearColor]];
    [[cell detailTextLabel] setBackgroundColor:[UIColor clearColor]];
    cell.textLabel.text = [[teamArray objectAtIndex:indexPath.row] autorelease];


    return cell;
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([[segue identifier] isEqualToString:@"Table"]){
        TeamTable1 *teams = [segue destinationViewController];
        NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
        if ([[teamArray objectAtIndex:indexPath.row] isEqual:@"East Cobb"]) {
            teams.teamsInt = 0;
            [teams setTitle:[teamArray objectAtIndex:indexPath.row]];
        }
        if ([[teamArray objectAtIndex:indexPath.row] isEqual:@"West Cobb"]) {
            teams.teamsInt = 1;
            [teams setTitle:[teamArray objectAtIndex:indexPath.row]];
        }
        if ([[teamArray objectAtIndex:indexPath.row] isEqual:@"Buckhead Thunder"]) {
            teams.teamsInt = 2;
            [teams setTitle:[teamArray objectAtIndex:indexPath.row]];
        }
        if ([[teamArray objectAtIndex:indexPath.row] isEqual:@"Fulton East"]) {
            teams.teamsInt = 3;
            [teams setTitle:[teamArray objectAtIndex:indexPath.row]];
        }
        if ([[teamArray objectAtIndex:indexPath.row] isEqual:@"Atlanta Braves"]) {
            teams.teamsInt = 4;
            [teams setTitle:[teamArray objectAtIndex:indexPath.row]];
        }
    }
}
@end
second table .h file

@interface TeamTable1 : UITableViewController{

    NSMutableArray *eastCobbArray;
    NSMutableArray *westCobbArray;
    NSMutableArray *buckheadThunderArray;
    NSMutableArray *fultonEastArray;
    NSMutableArray *atlantaBravesArray;

    NSMutableArray *sectionArray;
    NSMutableArray *data;

    int teamsInt;

}

@property int teamsInt;

- (void) makeData;

@end

second table .m file

@implementation TeamTable1
@synthesize teamsInt;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [sectionArray release];
    [data release];
    [eastCobbArray release];
    [westCobbArray release];
    [buckheadThunderArray release];
    [fultonEastArray release];
    [atlantaBravesArray release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad{
    [self makeData];
    [super viewDidLoad];
}

- (void) makeData
{
    data = [[NSMutableArray alloc] init];
    sectionArray = [[NSMutableArray alloc] init];

    eastCobbArray = [[NSMutableArray alloc] init];
    westCobbArray = [[NSMutableArray alloc] init];
    buckheadThunderArray = [[NSMutableArray alloc] init];
    fultonEastArray = [[NSMutableArray alloc] init];
    atlantaBravesArray = [[NSMutableArray alloc] init];

    if (teamsInt == 0) {
        [sectionArray addObject:@"East Cobb"];
    }
    if (teamsInt == 1) {
        [sectionArray addObject:@"West Cobb"];
    }
    if (teamsInt == 2) {
        [sectionArray addObject:@"Buckhead Thunder"];
    }
    if (teamsInt == 3) {
        [sectionArray addObject:@"Fulton East"];
    }
    if (teamsInt == 4) {
        [sectionArray addObject:@"Atlanta Braves"];
    }

    [eastCobbArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Coaches", @"name" , @"image1.JPG", @"image" , @"Mark Bayle 3rd Base\nSusane Ballor First Base\nJim Thally Pitching\nSam Bradley Batting", @"description", nil]];
    [eastCobbArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Team Outlook", @"name" , @"image2.jpg", @"image" , @"our team has won 26 out of the 35 and it is in first place. We have 2 players on DL and have recalled two players to replace them.", @"description", nil]];
    [eastCobbArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Schedule", @"name" , @"image3.jpg", @"image" , @"Sun June 30 VS Thunders @ Home\nMon June 31 VS Braves @ away\nTue July 1 VS East Cobb @ Home", @"description", nil]];
    [eastCobbArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Upcomming Events", @"name" , @"image4.jpg", @"image" , @"This is the list of the upcomming events for the month of july:\nJuly 1st:\nBake them all.\nJuly 2nd:\nFamily reunion\nJuly 3rd:\nSuppliers convention.", @"description", nil]];
    [eastCobbArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Roster", @"name" , @"image5.jpg", @"image" , @"Jim this 17\nTim duncan 22\nJim thalos 21\nFredrick nitche 24\n", @"description", nil]];

    [westCobbArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Coaches", @"name" , @"image1.JPG", @"image" , @"Mark Bayle 3rd Base\nSusane Ballor First Base\nJim Thally Pitching\nSam Bradley Batting", @"description", nil]];
    [westCobbArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Team Outlook", @"name" , @"image2.jpg", @"image" , @"our team has won 26 out of the 35 and it is in first place. We have 2 players on DL and have recalled two players to replace them.", @"description", nil]];
    [westCobbArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Schedule", @"name" , @"image3.jpg", @"image" , @"Sun June 30 VS Thunders @ Home\n Mon June 31 VS Braves @ away \n Tue July 1 VS East Cobb @ Home \n", @"description", nil]];
    [westCobbArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Upcomming Events", @"name" , @"image4.jpg", @"image" , @"This is the list of the upcomming events for the month of july:\nJuly 1st:\nBake them all.\nJuly 2nd:\nFamily reunion\nJuly 3rd:\nSuppliers convention.", @"description", nil]];
    [westCobbArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Roster", @"name" , @"image5.jpg", @"image" , @"Jim this 17\nTim duncan 22\nJim thalos 21\nFredrick nitche 24\n", @"description", nil]];

    [buckheadThunderArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Coaches", @"name" , @"image1.JPG", @"image" , @"Mark Bayle 3rd Base\nSusane Ballor First Base\nJim Thally Pitching\nSam Bradley Batting", @"description", nil]];
    [buckheadThunderArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Team Outlook", @"name" , @"image2.jpg", @"image" , @"our team has won 26 out of the 35 and it is in first place. We have 2 players on DL and have recalled two players to replace them.", @"description", nil]];
    [buckheadThunderArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Schedule", @"name" , @"image3.jpg", @"image" , @"Sun June 30 VS Thunders @ Home \n MOn June 31 VS Braves @ away \n Tue July 1 VS East Cobb @ Home \n", @"description", nil]];
    [buckheadThunderArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Upcomming Events", @"name" , @"image4.jpg", @"image" , @"This is the list of the upcomming events for the month of july:\nJuly 1st:\nBake them all.\nJuly 2nd:\nFamily reunion\nJuly 3rd:\nSuppliers convention.", @"description", nil]];
    [buckheadThunderArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Roster", @"name" , @"image5.jpg", @"image" , @"Jim this 17\nTim duncan 22\nJim thalos 21\nFredrick nitche 24\n", @"description", nil]];

    [fultonEastArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Coaches", @"name" , @"image1.JPG", @"image" , @"Mark Bayle 3rd Base\nSusane Ballor First Base\nJim Thally Pitching\nSam Bradley Batting", @"description", nil]];
    [fultonEastArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Team Outlook", @"name" , @"image2.jpg", @"image" , @"our team has won 26 out of the 35 and it is in first place. We have 2 players on DL and have recalled two players to replace them.", @"description", nil]];
    [fultonEastArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Schedule", @"name" , @"image3.jpg", @"image" , @"Sun June 30 VS Thunders @ Home \n MOn June 31 VS Braves @ away \n Tue July 1 VS East Cobb @ Home \n", @"description", nil]];
    [fultonEastArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Upcomming Events", @"name" , @"image4.jpg", @"image" , @"This is the list of the upcomming events for the month of july:\nJuly 1st:\nBake them all.\nJuly 2nd:\nFamily reunion\nJuly 3rd:\nSuppliers convention.", @"description", nil]];
    [fultonEastArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Roster", @"name" , @"image5.jpg", @"image" , @"Jim this 17\nTim duncan 22\nJim thalos 21\nFredrick nitche 24\n", @"description", nil]];


    [atlantaBravesArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Coaches", @"name" , @"image1.JPG", @"image" , @"Mark Bayle 3rd Base\nSusane Ballor First Base\nJim Thally Pitching\nSam Bradley Batting", @"description", nil]];
    [atlantaBravesArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Team Outlook", @"name" , @"image2.jpg", @"image" , @"our team has won 26 out of the 35 and it is in first place. We have 2 players on DL and have recalled two players to replace them.", @"description", nil]];
    [atlantaBravesArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Schedule", @"name" , @"image3.jpg", @"image" , @"Sun June 30 VS Thunders @ Home\nMon June 31 VS Braves @ away\nTue July 1 VS East Cobb @ Home\n", @"description", nil]];
    [atlantaBravesArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Upcomming Events", @"name" , @"image4.jpg", @"image" , @"This is the list of the upcomming events for the month of july:\nJuly 1st:\nBake them all.\nJuly 2nd:\nFamily reunion\nJuly 3rd:\nSuppliers convention.", @"description", nil]];
    [atlantaBravesArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Roster", @"name" , @"image5.jpg", @"image" , @"Jim this 17\nTim duncan 22\nJim thalos 21\nFredrick nitche 24\n", @"description", nil]];

    if (teamsInt == 0) {
        [data addObject:eastCobbArray];
    }
    if (teamsInt == 1) {
        [data addObject:westCobbArray];
    }
    if (teamsInt == 2) {
        [data addObject:buckheadThunderArray];
    }
    if (teamsInt == 3) {
        [data addObject:fultonEastArray];
    }
    if (teamsInt == 4) {
        [data addObject:atlantaBravesArray];
    }
}

- (void)viewDidUnload{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Table view data source

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return [sectionArray objectAtIndex:section];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    // Return the number of sections.
    return [sectionArray count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [[data objectAtIndex:section] count];
    [self.tableView reloadData];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell1";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell...
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:cell.frame];
    UIImage *image = [UIImage imageNamed:@"bgp.png"];
    imageView.image = image;
    cell.backgroundView = imageView;
    [[cell textLabel] setBackgroundColor:[UIColor clearColor]];
    [[cell detailTextLabel] setBackgroundColor:[UIColor clearColor]];
    cell.textLabel.text = [[[data objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] objectForKey:@"name"];

    return cell;
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([[segue identifier] isEqualToString:@"Detail"]){
        TeamDetail *teamDetail = [segue destinationViewController];
        NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
        if (teamsInt == 0)
        {
            teamDetail.teamImageString = [[NSString alloc] initWithString:[[eastCobbArray objectAtIndex:indexPath.row] objectForKey:@"image"]];
            teamDetail.teamTextString = [[NSString alloc] initWithString:[[eastCobbArray objectAtIndex:indexPath.row] objectForKey:@"description"]];
            teamDetail.title = [[NSString alloc] initWithString:[[eastCobbArray objectAtIndex:indexPath.row] objectForKey:@"name"]];
        }
        if (teamsInt == 1)
        {
            teamDetail.teamImageString = [[NSString alloc] initWithString:[[westCobbArray objectAtIndex:indexPath.row] objectForKey:@"image"]];
            teamDetail.teamTextString = [[NSString alloc] initWithString:[[westCobbArray objectAtIndex:indexPath.row] objectForKey:@"description"]];
            teamDetail.title = [[NSString alloc] initWithString:[[westCobbArray objectAtIndex:indexPath.row] objectForKey:@"name"]];
        }
        if (teamsInt == 2)
        {
            teamDetail.teamImageString = [[NSString alloc] initWithString:[[buckheadThunderArray objectAtIndex:indexPath.row] objectForKey:@"image"]];
            teamDetail.teamTextString = [[NSString alloc] initWithString:[[buckheadThunderArray objectAtIndex:indexPath.row] objectForKey:@"description"]];
            teamDetail.title = [[NSString alloc] initWithString:[[buckheadThunderArray objectAtIndex:indexPath.row] objectForKey:@"name"]];
        }
        if (teamsInt == 3)
        {
            teamDetail.teamImageString = [[NSString alloc] initWithString:[[fultonEastArray objectAtIndex:indexPath.row] objectForKey:@"image"]];
            teamDetail.teamTextString = [[NSString alloc] initWithString:[[fultonEastArray objectAtIndex:indexPath.row] objectForKey:@"description"]];
            teamDetail.title = [[NSString alloc] initWithString:[[fultonEastArray objectAtIndex:indexPath.row] objectForKey:@"name"]];
        }
        if (teamsInt == 4)
        {
            teamDetail.teamImageString = [[NSString alloc] initWithString:[[atlantaBravesArray objectAtIndex:indexPath.row] objectForKey:@"image"]];
            teamDetail.teamTextString = [[NSString alloc] initWithString:[[atlantaBravesArray objectAtIndex:indexPath.row] objectForKey:@"description"]];
            teamDetail.title = [[NSString alloc] initWithString:[[atlantaBravesArray objectAtIndex:indexPath.row] objectForKey:@"name"]];
        }
    }
}

@end

TeamDetail.h

@interface TeamDetail : UIViewController{

    IBOutlet UIImageView *teamImage;
    IBOutlet UITextView *teamText;
    NSString *teamImageString;
    NSString *teamTextString;
}

@property (nonatomic, retain) NSString *teamImageString;
@property (nonatomic, retain) NSString *teamTextString;

@end

TeamDetail.m

@implementation TeamDetail
@synthesize teamImageString, teamTextString;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bcp.png"]];
    teamImage.image = [UIImage imageNamed:teamImageString];
    teamText.text = teamTextString;

    // Do any additional setup after loading the view.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

now the connections and segue identifiers are fine and working it drills down all the way to detailview but only shows the first array information and sections and the rest of the arrays are not showing.

thanks in advance for your help

adrian

Was it helpful?

Solution

Anyway it seems that I find your mistake ) You obtain item like this, right:

if (teamsInt == 0)
        {
            teamDetail.teamImageString = [[NSString alloc] initWithString:[[eastCobbArray objectAtIndex:indexPath.row] objectForKey:@"image"]];
            teamDetail.teamTextString = [[NSString alloc] initWithString:[[eastCobbArray objectAtIndex:indexPath.row] objectForKey:@"description"]];
            teamDetail.title = [[NSString alloc] initWithString:[[eastCobbArray objectAtIndex:indexPath.row] objectForKey:@"name"]];
        }

But look carefully - you use indexPath.row but should use indexPath.section instead! Your row is always 0. Try this (ready for copy-paste ;)):

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([[segue identifier] isEqualToString:@"Detail"]){
        TeamDetail *teamDetail = [segue destinationViewController];
        NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
        if (teamsInt == 0)
        {
            teamDetail.teamImageString = [[NSString alloc] initWithString:[[eastCobbArray objectAtIndex:indexPath.section] objectForKey:@"image"]];
            teamDetail.teamTextString = [[NSString alloc] initWithString:[[eastCobbArray objectAtIndex:indexPath.section] objectForKey:@"description"]];
            teamDetail.title = [[NSString alloc] initWithString:[[eastCobbArray objectAtIndex:indexPath.section] objectForKey:@"name"]];
        }
        if (teamsInt == 1)
        {
            teamDetail.teamImageString = [[NSString alloc] initWithString:[[westCobbArray objectAtIndex:indexPath.section] objectForKey:@"image"]];
            teamDetail.teamTextString = [[NSString alloc] initWithString:[[westCobbArray objectAtIndex:indexPath.section] objectForKey:@"description"]];
            teamDetail.title = [[NSString alloc] initWithString:[[westCobbArray objectAtIndex:indexPath.section] objectForKey:@"name"]];
        }
        if (teamsInt == 2)
        {
            teamDetail.teamImageString = [[NSString alloc] initWithString:[[buckheadThunderArray objectAtIndex:indexPath.section] objectForKey:@"image"]];
            teamDetail.teamTextString = [[NSString alloc] initWithString:[[buckheadThunderArray objectAtIndex:indexPath.section] objectForKey:@"description"]];
            teamDetail.title = [[NSString alloc] initWithString:[[buckheadThunderArray objectAtIndex:indexPath.section] objectForKey:@"name"]];
        }
        if (teamsInt == 3)
        {
            teamDetail.teamImageString = [[NSString alloc] initWithString:[[fultonEastArray objectAtIndex:indexPath.section] objectForKey:@"image"]];
            teamDetail.teamTextString = [[NSString alloc] initWithString:[[fultonEastArray objectAtIndex:indexPath.section] objectForKey:@"description"]];
            teamDetail.title = [[NSString alloc] initWithString:[[fultonEastArray objectAtIndex:indexPath.section] objectForKey:@"name"]];
        }
        if (teamsInt == 4)
        {
            teamDetail.teamImageString = [[NSString alloc] initWithString:[[atlantaBravesArray objectAtIndex:indexPath.section] objectForKey:@"image"]];
            teamDetail.teamTextString = [[NSString alloc] initWithString:[[atlantaBravesArray objectAtIndex:indexPath.section] objectForKey:@"description"]];
            teamDetail.title = [[NSString alloc] initWithString:[[atlantaBravesArray objectAtIndex:indexPath.section] objectForKey:@"name"]];
        }
    }
}

p.s Consider about refactoring your code. Do not add objects to array, create it in one string like:

teamArray = [[NSMutableArray alloc] initWithObjects:@"East Cobb", @"West Cobb", @"Buckhead Thunder", @"Fulton East", @"Atlanta Braves", nil];

or:

teamArray = @[@"East Cobb", @"West Cobb", @"Buckhead Thunder", @"Fulton East", @"Atlanta Braves"];

Use switch instaed of if() with numerical values

>     teams.teamsInt = indexPath.row;
>     switch (indexPath.row) {
>         case:0
>         teams.title = [teamArray objectAtIndex:indexPath.row];
>         break;
>         //and so on
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top