iOS开发 ☞ KVC详解

来源:互联网 发布:广州java语言培训机构 编辑:程序博客网 时间:2024/06/05 16:07

一、Keys and Key Paths
Key

@interface Student : NSObject@property (nonatomic, copy) NSString *name;@property (nonatomic, assign) NSInteger *age;@end
 Student *student = [[Student alloc] init];    [student setValue:@"magic" forKey:@"name"];

Key Paths

@interface Teacher : NSObject@property (nonatomic, strong) Student *stu;@property (nonatomic, copy) NSString *name;@end
Teacher *teacher = [[Teacher alloc] init];    teacher.stu = [[Student alloc] init];    [teacher setValue:@"magic" forKeyPath:@"stu.name"];

二、Collection Operators

这里写图片描述

1 0
原创粉丝点击