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

IOS 解析JSON

时间:2015-10-07 06:15:26      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.navigationItem.leftBarButtonItem = self.editButtonItem;
    
    self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(reloadView:)
                                                name:@"reloadViewNotification"
                                            object:nil];
    
   NotesNextiveJsonParser *parser = [NotesNextiveJsonParser new];
  //开始解析
    [parser start];

    NSString* path = [[NSBundle mainBundle] pathForResource:@"Notes" ofType:@"json"];
    NSData *jsonData = [[NSData alloc] initWithContentsOfFile:path];
    
    NSError *error;
    
    id jsonObj = [NSJSONSerialization JSONObjectWithData:jsonData
                                                 options:NSJSONReadingMutableContainers error:&error];

    if (!jsonObj || error) {
        NSLog(@"JSON解码失败");
    }
    self.listData = [jsonObj objectForKey:@"Record"];
    
}

 

IOS 解析JSON

标签:

原文地址:http://www.cnblogs.com/zhongxuan/p/4858119.html

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