码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 从网络获取son并解析

时间:2015-10-18 16:53:40      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

NSString* GXURL = PURL;
    GXURL = [GXURL stringByAppendingString:@"/index.php/Api/android_getRankByShow/eid/521"],GXURL;
    NSURL* url = [NSURL URLWithString:GXURL];
    NSString* gongxian = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
    
    NSData * data = [gongxian dataUsingEncoding:NSUTF8StringEncoding];//将string 转换成 NSdata
    
    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];//将 NSdata转换成 字典
    
    //NSLog(@"%@",json);
    
    NSString* callBackData = [json valueForKey:@"data"];
    //NSLog(@"%@",callBackData);
    if([callBackData isEqual:@"0"])
    {
       
    }
    else
    {
        NSMutableArray *newList = [[NSMutableArray alloc] init];
        for(NSArray* item in callBackData)
        {
            NSString* nickname = [item valueForKey:@"nickname"];
            //NSLog(@"%@",nickname);
            
            NSString* gongxianStr = [NSString stringWithFormat:@"%@",nickname];
            [newList addObject:gongxianStr];
            
            
        }
        _list = newList;
        
        [_devoteTable reloadData];
        
    }

 

iOS 从网络获取son并解析

标签:

原文地址:http://www.cnblogs.com/voidcat/p/4889649.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!