I have this arrangement for my app, which downloads resources from a web service.
NSOperationQueue > NSOperation > ViewController > CustomTableViewCell
I have a weak delegate callback from NSOperation to the view controller.
This arrangement is fine. When my view controller dismisses, these objects stay in memory until the download finishes. Then they all deallocate nicely.
But if I bring the view controller back on screen during the download, the table view populates new cells (has new memory addresses). So the new cell at position 0 in the table view isn't receiving progress updates.
Progress is frequently sent via a block
I call this block from the view controller
Which gets it's progress from a block
I'm very confused. If anyone can shed any light on this, I would appreciate it.
Many thanks
NSOperationQueue > NSOperation > ViewController > CustomTableViewCell
I have a weak delegate callback from NSOperation to the view controller.
This arrangement is fine. When my view controller dismisses, these objects stay in memory until the download finishes. Then they all deallocate nicely.
But if I bring the view controller back on screen during the download, the table view populates new cells (has new memory addresses). So the new cell at position 0 in the table view isn't receiving progress updates.
Progress is frequently sent via a block
I call this block from the view controller
Code:
-(void)downloadResource:(Resource *)theResource
withProgress:(void (^)(NSNumber *progress))progressCallback
withSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))successCallback
withFailure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failureCallback
Which gets it's progress from a block
Code:
[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
float progress = (float)totalBytesRead / (float)totalBytesExpectedToRead;
progressCallback([NSNumber numberWithFloat:progress]);
}];
I'm very confused. If anyone can shed any light on this, I would appreciate it.
Many thanks