加载JSON时的活动指示符(微调器)

时间:2012-02-22 13:32:20

标签: ios json

如何在使用JSON加载数据并输入标签时显示微调器?

使用此代码调用JSON并将值放在标签中:

-(void)loadJSON {

    NSString *urlString = [NSString stringWithFormat:@"http://www.abc.com/service/?id=John&response=json"];
    NSURL *url = [NSURL URLWithString:urlString];
    data = [NSData dataWithContentsOfURL:url];

    NSError *error;

    json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

    NSDictionary *loan = [json objectForKey:@"person"];

    labelFirstName.text=[loan objectForKey:@"firstName"];
    labelLastName.text = [loan objectForKey:@"lastName"];
    labelNickName.text = [loan objectForKey:@"nickName"];
}

1 个答案:

答案 0 :(得分:0)

尝试使用MBProgressHUD加载Json。

研究这个 - https://github.com/jdg/MBProgressHUD