Reputation:
I have the following code in my cellForIndexPath but the pics are not in the right order:
NSURL *url = [NSURL URLWithString:[self.picturesArray objectAtIndex:indexPath.row]];
__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setCompletionBlock:^{
NSData *responseData = [request responseData];
cell.imageView.image = [UIImage imageWithData:responseData];;
}];
[request setFailedBlock:^{
NSError *error = [request error];
}];
[request startAsynchronous];
Upvotes: 0
Views: 423
Reputation: 16938
[I will change my answer then, since you changed the question entirely. :-) ]
So... images in the wrong cells?
Cell re-use is likely the issue. You're starting an asynchronous process to load an image for a cell. If that cell scrolls off the screen, that cell object will likely be re-used for another cell that comes into view. Meanwhile, the first image being loaded will continue to be loaded, unless you can notice that the cell has been re-used and/or cancel the previous load.
Are the images appearing in the wrong order when you scroll? Or, does this happen if you just launch the app and do not scroll the table?
Upvotes: 1