1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- //
- // FKUserFindAuthority.m
- // FirstLink
- //
- // Created by Lofty on 16/10/20.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKUserFindAuthority.h"
- #import "UserDefaultManager.h"
- #import "NSData+Base64.h"
- @implementation FKUserFindAuthority
- - (void)encodeWithCoder:(NSCoder *)aCoder{
- [aCoder encodeObject:self.type forKey:SHOPPING_LIVING_TYPE];
- [aCoder encodeObject:self.value forKey:SHOPPING_LIVING_VALUE];
- }
- - (instancetype)initWithCoder:(NSCoder *)aDecoder{
- if (self == [super init]) {
- self.type = [aDecoder decodeObjectForKey:SHOPPING_LIVING_TYPE];
- self.value = [aDecoder decodeObjectForKey:SHOPPING_LIVING_VALUE];
- }
- return self;
- }
- - (BOOL)isNeedShowDiscoverView{
- if (self.type.intValue == 1) {
- if (((NSString *)self.value).length > 0) {
- return YES;
- }
- } else if (self.type.intValue == 2) {
- if (((NSNumber *)self.value).intValue == 1) {
- return YES;
- }
- }
- return NO;
- }
- + (void)saveData:(FKUserFindAuthority *)authority{
-
- NSData *data = [NSKeyedArchiver archivedDataWithRootObject:authority];
- NSString* base64EncryptedString = [data base64EncodedString];
- [[UserDefaultManager sharedManager] setUserDefaultObject:base64EncryptedString key:SHOPPING_LIVING_USER_AUTHORITY];
- }
- + (FKUserFindAuthority *)analysisData{
- NSString *dataStr = [[UserDefaultManager sharedManager] getUserDefaultObject:SHOPPING_LIVING_USER_AUTHORITY];
- NSData *data = [NSData dataFromBase64String:dataStr];
- FKUserFindAuthority *userAuthority = [NSKeyedUnarchiver unarchiveObjectWithData:data];
- return userAuthority;
- }
- - (BOOL)isEqualToObject:(FKUserFindAuthority *)oldObject{
- if (self.type.integerValue != oldObject.type.intValue) {
- return NO;
- }
- if (self.type.intValue == 2) {
- NSNumber *number = (NSNumber *)self.value;
- NSNumber *oldNumber = (NSNumber *)oldObject.value;
- if (number.intValue != oldNumber.intValue) {
- return NO;
- }
- }else if(self.type.intValue == 1){
- NSString *urlStr = (NSString *)self.value;
- NSString *oldURLStr = (NSString *)oldObject.value;
- if (![urlStr isEqualToString:oldURLStr]) {
- return NO;
- }
- }
- return YES;
- }
- @end
|