12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- //
- // YOUPAILZBadgeModel.m
- // VQU
- //
- // Created by CY on 2021/9/6.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAILZBadgeModel.h"
- @implementation YOUPAILZBadgeModel
- - (instancetype)init
- {
- self = [super init];
- if (self) {
-
- }
- return self;
- }
- - (id) initWithCoder: (NSCoder *)decoder
- {
- if (self = [super init]) {
- unsigned int count = 0;
- //获取类中所有成员变量名
- Ivar *youpaipivar = class_copyIvarList([YOUPAILZBadgeModel class], &count);
- for (int i = 0; i<count; i++) {
- Ivar iva = youpaipivar[i];
- const char *name = ivar_getName(iva);
- NSString *strName = [NSString stringWithUTF8String:name];
- //进行解档取值
- id value = [decoder decodeObjectForKey:strName];
- //利用KVC对属性赋值
- if(value){
- [self setValue:value forKey:strName];
- }
- }
- free(youpaipivar);
- }
- return self;
- }
- - (void) encodeWithCoder: (NSCoder *)encoder
- {
- unsigned int count;
- Ivar *youpaipivar = class_copyIvarList([YOUPAILZBadgeModel class], &count);
- for (int i=0; i<count; i++) {
- Ivar iv = youpaipivar[i];
- const char *name = ivar_getName(iv);
- NSString *strName = [NSString stringWithUTF8String:name];
- //利用KVC取值
- id value = [self valueForKey:strName];
- [encoder encodeObject:value forKey:strName];
- }
- free(youpaipivar);
- }
- + (NSDictionary *)mj_replacedKeyFromPropertyName
- {
- return @{
- @"youpaipuser_id":@"user_id",
- @"youpaipid":@"id",
- @"youpaipname":@"name",
- @"youpaipfile":@"file",
- @"youpaippreview_img":@"preview_img",
- @"youpaipbig_preview_img":@"big_preview_img",
- @"youpaipwidth":@"width",
- };
- }
- @end
|