- (UITableViewCell *)tableView:(UITableView *)myTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UILabel *mainLabel, *secondLabel; UIImageView *photo; UITableViewCell * cell = [myTableView dequeueReusableCellWithIdentifier:@"rssItemCell"]; if(cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"rssItemCell"] autorelease]; cell.accessoryType = UITableViewCellAccessoryNone; mainLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 235.0, 15.0)] autorelease]; mainLabel.tag = MAINLABEL_TAG; mainLabel.font = [UIFont systemFontOfSize:14.0]; mainLabel.textAlignment = UITextAlignmentRight; mainLabel.textColor = [UIColor blackColor]; mainLabel.backgroundColor = [UIColor clearColor]; mainLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:mainLabel]; secondLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 20.0, 235.0, 25.0)] autorelease]; secondLabel.tag = MAINLABEL_TAG; secondLabel.font = [UIFont systemFontOfSize:10.0]; secondLabel.textAlignment = UITextAlignmentRight; secondLabel.textColor = [UIColor blackColor]; secondLabel.backgroundColor = [UIColor clearColor]; secondLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:secondLabel]; photo = [[[UIImageView alloc] initWithFrame:CGRectMake(238.0, 2.0, 80.0, 40.0)] autorelease]; photo.tag = PHOTO_TAG; photo.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:photo]; NSLog(@"calling list if nil"); } else { mainLabel = (UILabel *) [cell.contentView viewWithTag:MAINLABEL_TAG]; secondLabel = (UILabel *) [cell.contentView viewWithTag:SECONDLABEL_TAG]; photo = (UIImageView *) [cell.contentView viewWithTag:PHOTO_TAG]; } NSLog(@"calling list %d",indexPath.row); static NSDictionary* hasLoaded; RssData *data = [[[self rssParser] rssItems] objectAtIndex:indexPath.row]; mainLabel.text = [self ConvertNumToFarsi:[data title]]; secondLabel.text = [self ConvertNumToFarsi:[data description]]; // photo.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[data mediaUrl]]]]; [photo setImage:nil]; NSOperationQueue *queue = [NSOperationQueue new]; NSArray* argArray; argArray=[NSArray arrayWithObjects:data,photo,nil]; NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(loadImage:) object:(id)argArray]; [queue addOperation:operation]; [operation release]; //To customize the selected tableview cell //cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"effect"]]autorelease]; [cell setSelectionStyle:UITableViewCellSelectionStyleGray]; return cell; }