0

私が取り組んでいるプロジェクトがあり、UITableView をドリルダウンする必要があります。コードをストーリーボードに適合させ、最初の UITableView から 2 番目の UITableView にドリルダウンしますが、2 番目の UITableView で行を選択すると、配列の 1 つしか取得できません。他の行を選択すると、いずれかの行の詳細が表示されます。説明があいまいであることはわかっているので、より明確にするためにコードを含めています。どんな助けでも本当に感謝しています。

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

現在、接続とセグエ識別子は問題なく、詳細ビューまでドリルダウンしますが、最初の配列情報とセクションのみを表示し、残りの配列は表示されません。

あなたの助けを前もって感謝します

エイドリアン

4

1 に答える 1

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

ps コードのリファクタリングを検討してください。配列にオブジェクトを追加せず、次のように 1 つの文字列で作成します。

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 を使用する

>     teams.teamsInt = indexPath.row;
>     switch (indexPath.row) {
>         case:0
>         teams.title = [teamArray objectAtIndex:indexPath.row];
>         break;
>         //and so on
于 2012-10-05T21:14:45.287 に答える