0

我使用以下代码获取 JSON 结果,但出现错误:-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance. 我需要获取字符串格式的 JSON 并将其放入数组中,以便我可以使用它。

我的 refreshStream2 方法如下

-(void)refreshStream2 
    {

 [[API sharedInstance] commandWithParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:
                                             @"stream2",@"command",
                                             nil]
                               onCompletion:^(NSDictionary *json) {
                                   //got stream

  NSArray* list = [json objectForKey:@"result"];
                                NSLog(@"%@", list);
                                NSDictionary* photo = [list objectAtIndex:0];
                                NSLog(@"%@", photo);
                               [self showStream2:[photo objectForKey:@"Address"]];
     }];

}

然后我调用 showStream2 方法

-(void)showStream2:(NSArray*)stream {
     [_tableView reloadData];
     self.myList = [[NSMutableArray alloc] init];
     for (int i=0;i<10;i++) {
         NSDictionary* myTitle  = [stream objectAtIndex:i];   // I GET ERROR HERE!!
         [self.myList addObject: myTitle];
     }
 }

*JSON 输出* * **

2013-05-29 13:06:05.581 应用程序 [16335:907] ({ 地址 = test2; BarName = test1; }, { 地址 = test2; BarName = test; }, { Address = test2; BarName = test; }, { 地址 = test2; BarName = test; }, { Address = test2; BarName = test; }, { Address = test2; BarName = test; }, { Address = test2; BarName = test; }, { Address = test2; BarName = test; }, { 地址 = test2; BarName = test; }, { 地址 = test2; BarName = test; } )

4

0 回答 0