tags:

views:

56

answers:

1

Hi, i have set up a tableview with custom cells. customCell is a class. heres the code for a more accurate view:

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

 NSManagedObject *object = (NSManagedObject *)[entityArray objectAtIndex:indexPath.row];

 NSString *cellIdentifier = [NSString stringWithFormat:@"asd%d", indexPath.row];

 customCell *cell = [[tableView dequeueReusableCellWithIdentifier:cellIdentifier] autorelease];
 //i tried setting a tag but dunno how to call it afterwards
     [cell setTag:indexPath.row];

 if (cell == nil) {
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"customCell" owner:self options:nil];
  cell = [topLevelObjects objectAtIndex:0];
    }

 if (cell.imagen != nil) {
  [[cell imageView] setImage:[cell imagen]];
 } else { /* setup image... */ }
    }


    -(void) webImageReady:(WebImage *)downloadedImage imageView:(UIImageView *)imageView cellTag:(NSInteger *)cTag
    { 
     // This is the part where i want to access cell.imagen, this is actually wrong...
     [[[imageView.superview viewWithTag:cTag] imagen] setImagen:downloadedImage.Image];
     [imageView setImage:downloadedImage.Image];

    }

Ok. now i want to access (reference) the cell.imagen property from a method outside cellForRowAtIndexPath, more precisely at a selector for a download finished (delegated) Thanks in advance!

A: 

You shouldn't refer to the cell outside the cell creation method, you should consider the case the cell was rendered but while getting the image was scrolled out the dealloced or even reused for another cell, one way to solve it is to have image view array or something similar.

I think you should try using a third party lib that already doing it(among other things) called Three20. It have an object call TTImageView that gets a URL and loads it in the background, it solves all of the cases along with optimized caching

Guy Ephraim
Ok ill give it a try.. thanks
Nicolas
im having trouble linking Three20 to my project, any help would be much appreciated.
Nicolas
I'll be glad to help, anyway there is complete help on the Three20 project.
Guy Ephraim
Thanks! i followed the tutorial posted at three20.info and it works when i run it simulator but not on the device. the error is weird too:
Nicolas
“EXC_BAD_INSTRUCTION”.And xcode redirects me to TTImageView.m; - (id)initWithFrame:(CGRect)frame
Nicolas
Ok done some research.. I think this might be the solution: http://groups.google.com/group/three20/browse_thread/thread/9e0361058a2900d4/95094f97345dd7ab
Nicolas
Yep, that did the trick, along with "-all_load" in the linker flags on all targets AND executables build settings
Nicolas