JsonKit 解析

- (void)requestMapListData
{
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@""]];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];
    request.timeOutSeconds = 20.f;
    [request startAsynchronous];
}

- (void)requestFinished:(ASIHTTPRequest *)request
{
    NSData *requestData = [request responseData];
    NSString *dataStr = [[[NSString alloc] initWithData:requestData encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000)]autorelease];
    NSDictionary *dic = [dataStr objectFromJSONString];
    NSDictionary *dataDic = [dic objectForKey:@"data"];
    NSArray *dataArr = [dataDic objectForKey:@"list"];
    for (dataDic in dataArr) {
        GameRaiders *obj = [[[GameRaiders alloc]init]autorelease];
        [obj setMemberVariables:dataDic];
        [_dataArr addObject:obj];
    }
    
    GameRaiders *printObj = nil;
    for(int i=0; i< [_dataArr count];i++)
    {
        printObj = [_dataArr objectAtIndex:i];
        NSLog(@"title %@",printObj.title);
    }

}

- (void)requestFailed:(ASIHTTPRequest *)request
{
    NSLog(@"请求失败");
}

 

posted @ 2013-08-30 15:53  菜鸟程序猿  阅读(372)  评论(0编辑  收藏  举报