上篇博客說了利用MJExtension進行歸檔(http://www.itdecent.cn/p/d156ba42fd3a),本篇博客說說如何使用YYModel如何對自定義對象進行歸檔。
實際代碼也很簡單,只需在自定義類中重寫方法:
- (void)encodeWithCoder:(NSCoder*)aCoder {
? ? [self yy_modelEncodeWithCoder:aCoder];
}
- (id)initWithCoder:(NSCoder*)aDecoder
{
? ? self = [super init];
? ? return [self yy_modelInitWithCoder:aDecoder];
}
demo地址:https://gitee.com/liangsenliangsen/LiYongYYModelGuiDang
本篇文章到這里就結(jié)束了,愿大家加班不多工資多,男同胞都有女朋友,女同胞都有男朋友。??