您的位置:首页 > Web前端 > JavaScript

本地读取Json失败

2016-09-27 14:23 423 查看
直接向读取数组一样的        _AllARY = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Address" ofType:@"plist"]];

失败,则可以

       

        NSString *filePath = [[NSBundle mainBundle] pathForResource:@"city" ofType:@"json"];

        NSLog(@"filePath: %@", filePath);

        

        NSData *jsonData = [NSData dataWithContentsOfFile:filePath];

        NSLog(@"jsonData: %@", jsonData);

        

        NSError *error = nil;

        NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments|NSJSONReadingMutableLeaves error:&error];

        NSLog(@"jsonDict: %@", jsonDict);

        NSLog(@"error: %@", error);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: