Я разбираю XML-данные стороннего поставщика.Добавить поле для каждого объекта внутри массива
Они включают всю информацию, необходимую мне для каждой команды, за исключением их логотипа.
У меня есть все логотипы, импортированные в мой проект.
Есть ли способ добавить поле для логотипа в каждую команду?
Это мой метод синтаксического анализа, отлично работает
-(void) parseXML{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"apikeygoeshere"]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *xmlString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSDictionary *xml = [NSDictionary dictionaryWithXMLString:xmlString];
NSMutableArray *items = [xml objectForKey:@"TeamLeagueStanding"];
NSString *nullentry = @""; // custom code for specific reason
NSString *nullentry2 = @""; // custom code for a specific reason
[items insertObject:nullentry atIndex:0]; // custom code for a specific reason
[items insertObject:nullentry2 atIndex:1]; // custom code for a specific reason
[self setTableData:items];
}
Это мой метод cellForRowAtIndexPath, как вы увидите мои логотипы быть кормом из массива, что у меня есть в моем коде, но если команда, которая в 1-е место падает до 2, логотипы не изменит положение
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"StandingsIdent";
StandingsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSDictionary *item = [tableData objectAtIndex:[indexPath row]];
if ([item isKindOfClass:[NSDictionary class]]) {
long row = [indexPath row];
cell.cellTeamName.text = [item objectForKey:@"Team"];;
cell.cellTeamLogo.image = [UIImage imageNamed:_teamLogos[row]];
cell.cellTeamPosition.text = _teamPosition[row];
cell.cellPlayed.text = [item objectForKey:@"Played"];
cell.cellWins.text = [item objectForKey:@"Won"];
cell.cellTies.text = [item objectForKey:@"Draw"];
cell.cellLoses.text = [item objectForKey:@"Lost"]; ;
cell.cellPoints.text = [item objectForKey:@"Points"];
cell.cellInfo.text = _infoLeague[row];
}
else {
}
}
можно ли каким-то образом добавить эти логотипы к каждой команде? поэтому, когда команда «x» перемещает логотип, тоже.
Вот структура XML-данных после того, как разбираемый:
{
Draw = 10;
"Goal_Difference" = "-17";
"Goals_Against" = 39;
"Goals_For" = 22;
Lost = 11;
NumberOfShots = 395;
Played = 25;
PlayedAtHome = 13;
PlayedAway = 12;
Points = 22;
RedCards = 5;
Team = Partick;
"Team_Id" = 561;
Won = 4;
YellowCards = 41;
}
Спасибо;)
Разве это не случай обновления «tableData» с изображением на основе имени команды. Затем изображение будет перемещаться вместе с остальными данными? – trojanfoe