Luai Kalkatawi
Luai Kalkatawi

Reputation: 1492

Xcode parsing RSS XML with images issue

I am trying to parse text with images in the UITableView and I can only see the text for every line but I can't see the images.

Here is my code;

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

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [self.anaTablo dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}


    UILabel *textBaslik = (UILabel *) [cell viewWithTag:3];
    UIImage *imagePic = (UIImage *) [cell viewWithTag:7];

    textBaslik.text =[titleArray objectAtIndex:indexPath.row];
    imagePic.images = [imageArray objectAtIndex:indexPath.row];

return cell;

}

but it didn't works and after searching I have tried this to;

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

    UILabel *textBaslik = (UILabel *) [cell viewWithTag:3];
    UIImage *imagePic = (UIImage *) [cell viewWithTag:7];

    textBaslik.text =[titleArray objectAtIndex:indexPath.row]; 

    NSString *str1 = [[NSString alloc] initWithFormat:@"%@", imageArray];

    NSData *bgImageData = [NSData dataWithContentsOfFile:str1];

    UIImage *img1 = [UIImage imageWithData:bgImageData];

    imagePic = [img1 objectAtIndex:indexPath.row];

return cell

}

Am I doing something wrong? I am kind new to Xcode

Thanks from now.

Upvotes: 2

Views: 1230

Answers (2)

Aitul
Aitul

Reputation: 2992

I check you code and i change the following

NSString *str1 = [[NSString alloc] initWithFormat:@"%@", imageArray];
NSData *bgImageData = [NSData dataWithContentsOfFile:str1];
UIImage *img1 = [UIImage imageWithData:bgImageData];

imagePic = [imageArray objectAtIndex:indexPath.row];

cell.imageView.image=imagePic;

in the delegate method

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

Now a new error appear, check it

Upvotes: 3

Aitul
Aitul

Reputation: 2992

Check this tutorial about parsing RSS with XMLParses, it works perfectly. Wiki XML parse data

You should check this sample code using TBXML framework TBXML parser

Upvotes: 3

Related Questions