直接读取服务器的一个json 文件

    NSString *filePath = @"http://192.168.0.212:20000/ver.json";
    NSData *data =[NSData dataWithContentsOfURL:[NSURL URLWithString:filePath]];
    NSDictionary *dic = [data objectFromJSONData];
    NSLog(@"%@",dic);


ps :

objectFromJSONData是  JSONKit.h 里面的一个方法

JSONKit 请百度自行下载


这个是ver.json 里面的内容

{"version":"1.0","filename":"order.zip","version_type":"total"}

结果:

{
    filename = "order.zip";
    version = "1.0";
    "version_type" = total;

}



你可能感兴趣的:(IOS)