UI---JSON数据解析

 1 #import "AppDelegate.h"  
 2   
 3 @implementation AppDelegate  
 4   
 5 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions  
 6 {  
 7     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];  
 8     // Override point for customization after application launch.  
 9     self.window.backgroundColor = [UIColor whiteColor];  
10     [self.window makeKeyAndVisible];  
11       
12       
13     // 1.获得文件路径  
14     NSString *path = [[NSBundle mainBundle] pathForResource:@"studentJSON" ofType:@"txt"];  
15       
16     NSData *data = [NSData dataWithContentsOfFile:path];  
17       
18     // 2.json解析  
19     id object = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];  
20    // NSLog(@"%@", [object class]);  
21     NSLog(@"%@", object);  
22       
23       
24     [_window release];  
25     return YES;  
26 }  
27 -(void)dealloc  
28 {  
29     [_window release];  
30     [super dealloc];  
31 }  

 

posted @ 2016-06-06 15:35  超级马力  阅读(628)  评论(0编辑  收藏  举报