ibireme / YYKit

A collection of iOS components.
MIT License
13.99k stars 3.69k forks source link

add property copy and customize encoding/decoding methods #516

Open Roen-Ro opened 5 years ago

Roen-Ro commented 5 years ago
  1. 给YYModel添加了自定义 encode/decode方法

    -(BOOL)shouldCustomEncodeValueForKey:(NSString *)propertyKey withCoder:(NSCoder *)aCoder;
    -(BOOL)shouldCustomDecodeValueForKey:(NSString *)propertyKey withCoder:(NSCoder *)aDecoder;

    程序员可以在子类重写这两个方法来自定义一些属性的encode/decode,比如一些struct结构体,或者做一些历史版本数据的兼容,就很必要用到这两个方法。

  2. 给YYModel添加了从其他对象拷贝属性的方法 添加的方法:

    -(void)copyPropertiesFromSourceObject:(id)sourceObj

    通过这个方法将一个对象A的属性全部拷贝到已有的对象B上,而不需要新建创建对象