1.本地地址解析

   NSString*path =@"/Users/ivan/Desktop/movie.txt";

   
   
//表示二进制的对象
   
NSData *data = [NSData dataWithContentsOfFile:path];

   

    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
   
   
NSDictionary *resultDic = dic[@"result"];
   
   
NSString *rating = resultDic[@"desc"];

    NSLog(@"%@",rating);


2.网络地址解析

    NSString *path = [NSString stringWithFormat:@"http://apis.juhe.cn/cook/query?key=80996127f667eac43832103850b3b13a&menu=%@",self.menuName];

    path = [path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];//因为识别汉字,所以将字符串用UTF8解码

 

    NSURL *url = [NSURL URLWithString:path];//NSURL就是网页地址

    NSData *data = [NSData dataWithContentsOfURL:url];
   
   
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];