I'm new to objective-c programming and I'm writing application which uses XML files as data source. I've got class Score with init:
- (id)initWithPlayer1Name:(NSString *)name1 Player2Name:(NSString *)name2 Player1Url:(NSString *)url1 Player2Url:(NSString *)url2 Player1FrameScore:(NSString *)frame1 Player2FrameScore:(NSString *)frame2 Player1InFrameScore:(NSString *)score1 Player2InFrameScore:(NSString *)score2
{
if(self = [super init])
{
self.name1 = name1;
self.name2 = name2;
self.url1 = url1;
self.url2 = url2;
self.image1 = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url1]]];
self.image2 = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url2]]];
self.frame1 = frame1;
self.frame2 = frame2;
self.score1 = score1;
self.score2 = score2;
}
return self;
}
And I want to display list of scores in table view. When application starts there are some sample data and table view with my custom cell (display 2 names and 2 images from score class in every row) works fine. Problems begin when I update data from XML (I'm using XMLParser - works well). Players names are updated, but images disappears. In other table view I've got list of players in custom cell but with only one picture and it works fine.
Here is code from scores table view class:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ScoresCell";
ScoresCell *cell = (ScoresCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = (ScoresCell*) [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Score *score = [self.scores objectAtIndex:indexPath.row];
cell.player1Name.text = score.name1;
cell.player1Image.image = score.image1;
cell.player2Name.text = score.name2;
cell.player2Image.image = score.image1;
return cell;
}
I was testing it in many ways, but I have not found a solution.