Objective c 延迟加载用户映像UITableView-更新请求块中的映像不起作用

Objective c 延迟加载用户映像UITableView-更新请求块中的映像不起作用,objective-c,uitableview,lazy-loading,objective-c-blocks,afnetworking,Objective C,Uitableview,Lazy Loading,Objective C Blocks,Afnetworking,因此,我正在尝试为自定义UITableView BubbletTableView加载用户图片 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"GET"]; AFImageRequestOperation *operation = [AFImageRequestOperation ima

因此,我正在尝试为自定义UITableView BubbletTableView加载用户图片

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
                [request setHTTPMethod:@"GET"];

                AFImageRequestOperation *operation = [AFImageRequestOperation imageRequestOperationWithRequest:request imageProcessingBlock:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {

                    NSLog(@"Success");
                    UIBubbleTableViewCell *cell = (UIBubbleTableViewCell *)[self.bubbleTableView cellForRowAtIndexPath:indexPath];
                    NSBubbleData *data = [[NSBubbleData alloc] init];
                    data = [cell data];
                    data.avatar = [UIImage imageNamed:@"send.png"];
                    [self.profileImages setObject:image forKey:[self.commUsers objectAtIndex:x]];
                    //Success
                    [cell setData:data];

                } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
                    //Failed
                    NSLog(@"ERROR: %@", response);
                }];

                [operation start];
我正在尝试将化身更改为另一个图像,我没有使用从网络中提取的图像,而只是为了缩小图像更新问题而在本地存储的图像

所以如果我把

 UIBubbleTableViewCell *cell = (UIBubbleTableViewCell *)[self.bubbleTableView cellForRowAtIndexPath:indexPath];
                NSBubbleData *data = [[NSBubbleData alloc] init];
                data = [cell data];
                data.avatar = [UIImage imageNamed:@"send.png"];
                [self.profileImages setObject:image forKey:[self.commUsers objectAtIndex:x]];
                //Success
                [cell setData:data];
在AFImageRequestOperation块中,图像不会更新。但是,如果我将完全相同的代码放在块外,它会更新图像。我觉得我在积木的工作原理上遗漏了一些东西。我该如何解决这个问题


谢谢

尝试在主线程的块中运行UI代码:

if ([NSThread isMainThread]) {
    // We're currently executing on the main thread.
    // We can execute the block directly.
    createBubbleTableViewCell();
  } else {
   //non-blocking call to main thread
   dispatch_sync(dispatch_get_main_queue(), createBubbleTableViewCell);
}
检查是否在主线程上只是为了防止死锁。还可以使用dispatch\u async阻止调用

UI代码应始终在主线程上运行