iOS forUndefinedKey你知道吗?

不用runtime,直接kvc

添加初始化方法

- (instancetype)initWithDictionary:(NSDictionary*)dictionary{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dictionary];
    }
    return self;
}

重写
- (void)setValue:(id)value forUndefinedKey:(NSString *)key

爽~~

你可能感兴趣的:(iOS forUndefinedKey你知道吗?)