钻取tableview

时间:2012-10-05 17:40:56

标签: objective-c drilldown

我有一个正在处理的项目,它需要向下钻取UITableView。我已经将我的代码调整到了故事板,它从第一个UITableView到第二个UITableView都很顺利但是当我在第二个UITableView中选择行时,我只获得了一个数组。当选择任何其他行时,它只显示其中一行的详细信息。我知道描述含糊不清所以我将我的代码包括在内以便进一步澄清。真的很感激任何帮助。

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

现在连接和segue标识符很好,并且它一直向下钻到detailview,但只显示第一个数组信息和部分,其余的数组没有显示。

提前感谢您的帮助

阿德里安

1 个答案:

答案 0 :(得分:0)

无论如何,似乎我发现你的错误) 您可以获得这样的项目,右:

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"]];
        }

但仔细看 - 你使用indexPath.row但是应该使用indexPath.section!你的行总是0。 试试这个(准备复制粘贴;)):

- (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考虑重构代码。    不要将对象添加到数组,在一个字符串中创建它,如:

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

或:

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

使用if()的switch instaed和数值

>     teams.teamsInt = indexPath.row;
>     switch (indexPath.row) {
>         case:0
>         teams.title = [teamArray objectAtIndex:indexPath.row];
>         break;
>         //and so on