No Description

FKUserFindAuthority.m 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // FKUserFindAuthority.m
  3. // FirstLink
  4. //
  5. // Created by Lofty on 16/10/20.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKUserFindAuthority.h"
  9. #import "UserDefaultManager.h"
  10. #import "NSData+Base64.h"
  11. @implementation FKUserFindAuthority
  12. - (void)encodeWithCoder:(NSCoder *)aCoder{
  13. [aCoder encodeObject:self.type forKey:SHOPPING_LIVING_TYPE];
  14. [aCoder encodeObject:self.value forKey:SHOPPING_LIVING_VALUE];
  15. }
  16. - (instancetype)initWithCoder:(NSCoder *)aDecoder{
  17. if (self == [super init]) {
  18. self.type = [aDecoder decodeObjectForKey:SHOPPING_LIVING_TYPE];
  19. self.value = [aDecoder decodeObjectForKey:SHOPPING_LIVING_VALUE];
  20. }
  21. return self;
  22. }
  23. - (BOOL)isNeedShowDiscoverView{
  24. if (self.type.intValue == 1) {
  25. if (((NSString *)self.value).length > 0) {
  26. return YES;
  27. }
  28. } else if (self.type.intValue == 2) {
  29. if (((NSNumber *)self.value).intValue == 1) {
  30. return YES;
  31. }
  32. }
  33. return NO;
  34. }
  35. + (void)saveData:(FKUserFindAuthority *)authority{
  36. NSData *data = [NSKeyedArchiver archivedDataWithRootObject:authority];
  37. NSString* base64EncryptedString = [data base64EncodedString];
  38. [[UserDefaultManager sharedManager] setUserDefaultObject:base64EncryptedString key:SHOPPING_LIVING_USER_AUTHORITY];
  39. }
  40. + (FKUserFindAuthority *)analysisData{
  41. NSString *dataStr = [[UserDefaultManager sharedManager] getUserDefaultObject:SHOPPING_LIVING_USER_AUTHORITY];
  42. NSData *data = [NSData dataFromBase64String:dataStr];
  43. FKUserFindAuthority *userAuthority = [NSKeyedUnarchiver unarchiveObjectWithData:data];
  44. return userAuthority;
  45. }
  46. - (BOOL)isEqualToObject:(FKUserFindAuthority *)oldObject{
  47. if (self.type.integerValue != oldObject.type.intValue) {
  48. return NO;
  49. }
  50. if (self.type.intValue == 2) {
  51. NSNumber *number = (NSNumber *)self.value;
  52. NSNumber *oldNumber = (NSNumber *)oldObject.value;
  53. if (number.intValue != oldNumber.intValue) {
  54. return NO;
  55. }
  56. }else if(self.type.intValue == 1){
  57. NSString *urlStr = (NSString *)self.value;
  58. NSString *oldURLStr = (NSString *)oldObject.value;
  59. if (![urlStr isEqualToString:oldURLStr]) {
  60. return NO;
  61. }
  62. }
  63. return YES;
  64. }
  65. @end