简体   繁体   English

prepareForSegue比较数组和字典中的值

[英]prepareForSegue comparing values from array and dictionary

I need help coding my prepareForSegue: 我需要编码我的prepareForSegue:帮助prepareForSegue:

This TeamObject holds a teamID value, it can be, 55...65...etc. 这个TeamObject拥有一个teamID值,可以是55 ... 65 ... teamID

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *CellIdentifier = @"StandingsIdent";

    StandingsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    TeamObject *item = [tableData objectAtIndex:[indexPath row]];

    long row = [indexPath row];

        if ([item isKindOfClass:[TeamObject class]]) {

            cell.cellTeamName.text = item.teamName;
            cell.cellTeamLogo.image = item.teamLogo;
            cell.cellPlayed.text = item.matchesPlayed;
            cell.cellWins.text = item.wins;
            cell.cellTies.text = item.ties;
            cell.cellLoses.text = item.loses;
            cell.cellPoints.text = item.points;
            cell.cellTeamPosition.text = _teamPosition[row];
            cell.cellInfo.text = _infoLeague[row];
        }

        else {

        }

My viewDidLoad, has a few dictionaries, that hold keys for each objects: 我的viewDidLoad有一些字典,这些字典保存每个对象的键:

- (void)viewDidLoad {

    [super viewDidLoad];


    _testThis = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                    @"2", @"1478.png",
                    @"3", @"1487.png",
                    @"4", @"1489.png",
                    @"5", @"1494.png",
                    @"6", @"1474.png",
                    @"7", @"2390.png",
                    @"8", @"2433.png",
                    @"9", @"1488.png",
                    @"10", @"1481.png",
                    @"11", @"2383.png",
                    @"12", @"1476.png",
                    @"13", @"1495.png",
                    @"14", @"729500.png",
                    @"15", @"2386.png",
                    @"16", @"2445.png",
                    @"17", @"2393.png",
                    nil];

Now i need my prepareForSegue to do this logic, if teamId in TeamObject , matches team id in dictionary, send the info trough... 现在我需要我的prepareForSegue来执行此逻辑,如果teamId中的TeamObject匹配字典中的团队ID,则发送信息槽...

The way i have it coded it's static, and my teams change positions everyday, so i need this segue to know what he is doing when showing additional information. 我使用的编码方式是静态的,我的团队每天都会更改职位,因此我需要此命令才能知道他在显示其他信息时正在做什么。

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([[segue identifier] isEqualToString:@"teamDetailsSeg"]){


        TeamDetailsTableViewController *detailViewController = [segue destinationViewController];

        NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow];
        long row = [myIndexPath row];

        if ([TeamObject o

        detailViewController.teamDetailModel = @[_teamFullNames[row], _teamLogos[row], _teamStadiumPictures[row], _teamStadiumNames[row], _stadiumCapacity[row], _stadiumBuiltYear[row], _clubFoundationDate[row], _teamCity[row], _clubPresident[row], _headCoach[row], _championshipsWon[row], _domesticCupsWon[row], _domesticLeagueCupsWon[row], _domesticSuperCupsWon[row], _championsleaguesWon[row], _europaleaguesWon[row], _europeanSuperCupsWon[row], _worldclubchampionshipsWon[row]];
    }
}

This is the code for my ExtraDetailsViewController , everything works, but it's static, so if tomorrow the team in 1st place drops to 2nd, the extra additional data will not be correct. 这是我的ExtraDetailsViewController的代码,一切正常,但它是静态的,因此,如果明天第一名的团队ExtraDetailsViewController第二名,则额外的额外数据将不正确。

- (void)viewDidLoad
{
    [super viewDidLoad];

    _cellFullTeamName.text = _teamDetailModel[0];
    _cellTeamLogo.image = [UIImage imageNamed:_teamDetailModel[1]];
    _cellTeamStadium.image = [UIImage imageNamed:_teamDetailModel[2]];
    _cellStadiumName.text = _teamDetailModel[3];
    _cellStadiumCapacity.text = _teamDetailModel[4];
    _cellStadiumYear.text = _teamDetailModel[5];
    _cellClubYear.text = _teamDetailModel[6];
    _cellStadiumCity.text = _teamDetailModel[7];
    _cellPresident.text = _teamDetailModel[8];
    _cellCoach.text = _teamDetailModel[9];
    _cellDomesticChampionships.text = _teamDetailModel[10];
    _cellDomesticCups.text = _teamDetailModel[11];
    _cellDomesticLeagueCups.text = _teamDetailModel[12];
    _cellDomesticSupercups.text = _teamDetailModel[13];
    _cellChampionsLeagues.text = _teamDetailModel[14];
    _cellEuroLeagues.text = _teamDetailModel [15];
    _celLEuroSuperCups.text = _teamDetailModel[16];
    _cellIntertoto.text = _teamDetailModel [17];


}

Can anyone help? 有人可以帮忙吗?

Thanks. 谢谢。

TeamObject *item = [tableData objectAtIndex:row]; 

if([_testThis valueForKey:item.teamID]{
            //send data through 
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM