下面是我处理本地解析json的代码:是在网络返回数据都已经获取到之后执行的,如果返回true就alert出来。如果返回的是error,这个数据是通过json数据封装的,就可以通过SBJSON解析,下面调用的是解析的代码。在类开始的地方还需要加入

#import "SBJson.h" 主要是这里面加入json的类包

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {

    if (nil != BusyAlert)

        [BusyAlertdismissWithClickedButtonIndex:0animated:YES];  

    downloadedBytes = totalBytes;

    NSString *tempString = [[NSStringalloc] initWithData: downloadedDataencoding:NSUTF8StringEncoding];

    if ([tempString isEqualToString:@"true"]) {

            UIAlertView* alert = [[UIAlertViewalloc] initWithTitle:@"提示"message:@"注册成功!" delegate:nilcancelButtonTitle:@"OK"otherButtonTitles:nil, nil];

            [alert show];

            [alert release];

    }

    else {

        NSMutableDictionary *dic = [tempString JSONValue];

        NSString *partnerCodeString = [NSString stringWithFormat:@"%@",[dic objectForKey:@"error"]];

        UIAlertView* alert = [[UIAlertViewalloc] initWithTitle:@"提示"message:partnerCodeString delegate:nilcancelButtonTitle:@"OK"otherButtonTitles:nil, nil];

        [alert show];

        [alert release];

    }

    downloadedData = nil;

}

相关文章:

  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-11
  • 2021-08-06
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
  • 2022-12-23
相关资源
相似解决方案