0
NSString *pictureUrl = [[[oneUserDict objectForKey:@"picture"]objectForKey:@"data"]objectForKey:@"url"];

[[AppEngine sharedEngine]imageAtURL:[NSURL URLWithString:pictureUrl] onCompletion:^(UIImage *fetchedImage, NSURL *url, BOOL isInCache) 

{
  int index  = [usersArray indexOfObject:oneUserDict];
  NSString *loadName = [NSString stringWithFormat:@"%d of %d",index,[usersArray count]];
  NSLog(@"%i",usersArray.count);
  int temp=[usersArray count]-10;

  if (index!=temp) 
  {

    [[LoadingIndicator currentIndicator]displayActivity:loadName];
    NSLog(@"inside loading indicator");
  }

  else
  {

   [[LoadingIndicator currentIndicator]displayCompleted:@"Done"];
     NSLog(@"finally done");
  }

    aPerson.image =  UIImagePNGRepresentation(fetchedImage);
    [appDelegate.managedObjectContext save:nil];
 }];

AppEngine 是它的子类,MKNetworkEngine它使用一个名为imageAtURL:onCompletion:

我目前正在做的是从特定的 url 中检索所有图像并将它们存储在 aPerson.image 中,基本上上面的代码是在一个 FOR 循环中(即用于用户计数)。

问题

完成块中的上述代码永远不会被执行,我不知道为什么,但我在块内放置了一个断点,但编译器仍然不会在完成块内运行语句。

4

1 回答 1

1

Api imageAtURL:onCompletion: is deprecated. Use imageAtURL:completionHandler:errorHandler: instead. Also MKNetworkKit provides for UIImageView+MKNetworkKitAdditions category which provides simple API for image download like setImageFromURL: placeHolderImage:

Cheers!
Amar.

于 2013-05-17T10:02:59.167 回答