iOS forUndefinedKey你知道吗?

2019-08-22  本文已影响0人  DL是谁

不用runtime,直接kvc

添加初始化方法

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

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

爽~~

上一篇下一篇

猜你喜欢

热点阅读