Ios MWphotobrowser-从Json获取图像

Ios MWphotobrowser-从Json获取图像,ios,objective-c,json,mwphotobrowser,Ios,Objective C,Json,Mwphotobrowser,我试图弄清楚如何从外部服务器的json文件中获取照片、照片标题、照片缩略图等 在viewDidLoad中,我有以下代码: - (void)viewDidLoad { NSURL *url = [NSURL URLWithString:@"https://s3.amazonaws.com/mobile-makers-lib/superheroes.json"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [super

我试图弄清楚如何从外部服务器的json文件中获取照片、照片标题、照片缩略图等

在viewDidLoad中,我有以下代码:

- (void)viewDidLoad {

NSURL *url = [NSURL URLWithString:@"https://s3.amazonaws.com/mobile-makers-lib/superheroes.json"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

[super viewDidLoad];

[NSURLConnection sendAsynchronousRequest:request
                                   queue:[NSOperationQueue mainQueue]
                       completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError)

 {

     NSLog(@"Back from the web");
 }];

NSLog(@"Just made the web call");

}
在Case3 MWphotobrowser的Menu.m中,我有以下代码:

case 3: {

       photo.caption = [self.result valueForKeyPath:@"name"];

        NSArray * photoURLs = [self.result valueForKeyPath:@"avatar_url"];
        NSString * imageURL = [photoURLs objectAtIndex:indexPath.row];

        [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:imageURL]]];



        enableGrid = NO;
        break;

    }
万一你错过了,我使用的JSON文件是

我所做的任何调整似乎都不能让它工作,有什么办法可以解决这个问题吗

[NSURLConnection sendAsynchronousRequest:request
                               queue:[NSOperationQueue mainQueue]
                   completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError)

 {

    // here make sure ur response is getting or not

     if ([data length] >0 && connectionError == nil)
     {

         // DO YOUR WORK HERE


          self.superheroes = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingMutableContainers error: &connectionError];

           NSLog(@"data downloaded.==%@",  self.superheroes);

     }
     else if ([data length] == 0 && connectionError == nil)
     {
         NSLog(@"Nothing was downloaded.");
     }
     else if (connectionError != nil){
         NSLog(@"Error = %@", connectionError);
     }



   }];
在这里,从服务器得到的响应是
NSArray-->
NSMutableDictionary`so

案例
场景为

case 3: {


        NSDictionary *superhero = [self.superheroes objectAtIndex:indexPath.row];




       photo.caption = superhero[@"name"];

        NSString * imageURL = superhero[@"avatar_url"];

      //  NSArray * photoURLs = superhero[@"avatar_url"];


        [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:imageURL]]];




        enableGrid = NO;
        break;

    }
你最后的出局是


self.result中得到的结果通常来自[array{dictionary}格式,也就是我问的。在Menu.h中,我有@property(非原子,强)NSMutableDictionary*结果;错了吗?祝你有个快乐的一天,