猎豆优选

AccountModel.m 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // AccountModel.m
  3. // CommerceManage
  4. //
  5. // Created by 小花 on 2016/12/27.
  6. // Copyright © 2016年 vaic. All rights reserved.
  7. //
  8. #import "AccountModel.h"
  9. @implementation AccountModel
  10. //+ (instancetype)AccountStatusWithDict:(NSDictionary *)dict {
  11. // AccountModel *account = [[self alloc] init];
  12. // account.token = dict[@"token"];
  13. //
  14. // return account;
  15. //}
  16. /**
  17. * 当一个对象要归档进沙盒的时候就会调用 归档
  18. * 目的,在这个方法中说明这个对象的哪些属性写进沙盒
  19. * @param encoder <#encoder description#>
  20. */
  21. - (void)encodeWithCoder:(NSCoder *)encoder
  22. {
  23. [encoder encodeObject:self.token forKey:@"token"];
  24. [encoder encodeObject:self.unionid forKey:@"unionid"];
  25. [encoder encodeObject:self.openId forKey:@"openId"];
  26. [encoder encodeObject:self.nickname forKey:@"nickname"];
  27. //
  28. }
  29. /**
  30. * 反归档 的时候会调用这个方法 解档
  31. * 目的:在这个方法中说明这个对象的哪些属性从沙河中解析出来
  32. 从沙河中解析对象 反归档会调用这个方法 需要解析哪些属性
  33. * @param decoder <#decoder description#>
  34. *
  35. * @return <#return value description#>
  36. */
  37. -(instancetype)initWithCoder:(NSCoder *)decoder
  38. {
  39. if (self = [super init]) {
  40. self.token = [decoder decodeObjectForKey:@"token"];
  41. self.unionid = [decoder decodeObjectForKey:@"unionid"];
  42. self.openId = [decoder decodeObjectForKey:@"openId"];
  43. self.nickname = [decoder decodeObjectForKey:@"nickname"];
  44. }
  45. return self;
  46. }
  47. @end