YOUPAIHRsendRankModel.m 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // YOUPAIHRsendRankModel.m
  3. // VQU
  4. //
  5. // Created by xiaohaoran on 2021/10/21.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIHRsendRankModel.h"
  9. @implementation YOUPAIHRsendRankModel
  10. - (instancetype)init
  11. {
  12. self = [super init];
  13. if (self) {
  14. }
  15. return self;
  16. }
  17. - (id) initWithCoder: (NSCoder *)decoder
  18. {
  19. if (self = [super init]) {
  20. unsigned int count = 0;
  21. //获取类中所有成员变量名
  22. Ivar *ivar = class_copyIvarList([YOUPAILCBaseInfo class], &count);
  23. for (int i = 0; i<count; i++) {
  24. Ivar iva = ivar[i];
  25. const char *name = ivar_getName(iva);
  26. NSString *strName = [NSString stringWithUTF8String:name];
  27. //进行解档取值
  28. id value = [decoder decodeObjectForKey:strName];
  29. //利用KVC对属性赋值
  30. if(value){
  31. [self setValue:value forKey:strName];
  32. }
  33. }
  34. free(ivar);
  35. }
  36. return self;
  37. }
  38. - (void) encodeWithCoder: (NSCoder *)encoder
  39. {
  40. unsigned int count;
  41. Ivar *ivar = class_copyIvarList([YOUPAILCBaseInfo class], &count);
  42. for (int i=0; i<count; i++) {
  43. Ivar iv = ivar[i];
  44. const char *name = ivar_getName(iv);
  45. NSString *strName = [NSString stringWithUTF8String:name];
  46. //利用KVC取值
  47. id value = [self valueForKey:strName];
  48. [encoder encodeObject:value forKey:strName];
  49. }
  50. free(ivar);
  51. }
  52. + (NSDictionary *)mj_replacedKeyFromPropertyName
  53. {
  54. return @{
  55. @"youpaipgrade":@"grade",
  56. @"youpaiprankInfo":@"rankInfo",
  57. @"youpaipavatar":@"avatar",
  58. @"youpaipavatar_frame":@"avatar_frame",
  59. @"youpaipcreatetime":@"createtime",
  60. @"youpaipexprise_in":@"exprise_in",
  61. @"youpaipexprisetime":@"exprisetime",
  62. @"youpaiptoken":@"token",
  63. @"youpaipid":@"id",
  64. @"youpaipnickname":@"nickname",
  65. @"youpaipis_follow":@"is_follow",
  66. @"youpaipremark_name":@"remark_name",
  67. @"youpaipgender":@"gender",
  68. @"youpaipis_anchor":@"is_anchor",
  69. @"youpaipamount":@"amount",
  70. @"youpaipvip":@"vip",
  71. @"youpaipvip_icon":@"vip_icon",
  72. @"youpaipvip_expire":@"vip_expire",
  73. @"youpaipvip_des":@"vip_des",
  74. @"youpaipis_msg_refuse":@"is_msg_refuse",
  75. @"youpaipis_live":@"is_live",
  76. @"youpaipsign":@"sign",
  77. @"youpaipbadge_info":@"badge_info",
  78. @"youpaipmsg":@"msg",
  79. };
  80. }
  81. @end