码迷,mamicode.com
首页 > 其他好文 > 详细

KVC的应用

时间:2014-10-17 21:48:27      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:io   ar   for   sp   on   cti   log   ad   ef   

//    Student *stu=[[Student alloc]init];

//    [stu setValue:@12 forKey:@"age"];

//    [stu setValue:@14 forKey:@"_age"];

//    [stu setValue:@"zhangsan" forKey:@"name"];

//    [stu setValue:@"lisi" forKey:@"_name"];

//    [stu call];

//    

//    Book *book=[[Book alloc]init];

//    [stu setValue:book forKey:@"book"];

//    

//    [stu setValue:@"nihao" forKeyPath:@"book.title"];

//    [stu call];

    

    

//    NSString *path=[[NSBundle mainBundle]pathForResource:@"json" ofType:@"txt"];

//    NSString *jsonStr=[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];

//    NSDictionary *dict=[NSJSONSerialization JSONObjectWithData:[jsonStr dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil];

//    

//    News *news=[[News alloc]init];

//    [news setValuesForKeysWithDictionary:dict];

//    NSLog(@"%@",news.Name);

//    NSLog(@"----");

    

//    Student *s1=[[Student alloc]init];

//    s1.age=12;

//    Student *s2=[[Student alloc]init];

//    s2.age=13;

//    Student *s3=[[Student alloc]init];

//    s3.age=14;

//    Student *s4=[[Student alloc]init];

//    s4.age=15;

//    NSArray *arr=@[s1,s2,s3,s4];

//    NSLog(@"%@",[arr valueForKey:@"@count"]);

//    NSLog(@"%@",[arr valueForKeyPath:@"@min.age"]);

//    NSLog(@"%@",[arr valueForKeyPath:@"@sum.age"]);

KVC的应用

标签:io   ar   for   sp   on   cti   log   ad   ef   

原文地址:http://www.cnblogs.com/a514875560/p/4032099.html

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