LoginMethods.h+ (void)setLoginModel:(LoginModel *)loginModel;
+ (LoginModel *)getLoginModel;
+ (BOOL)judgeLogin;
+ (void)logout;+ (void)setLoginModel:(LoginModel *)loginModel {
[[NSUserDefaults standardUserDefaults] setObject:[NSKeyedArchiver archivedDataWithRootObject:loginModel] forKey:loginModelKey];
}
+ (LoginModel *)getLoginModel {
NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:loginModelKey];
LoginModel *loginModel = [NSKeyedUnarchiver unarchiveObjectWithData:data];
return loginModel;
}
+ (BOOL)judgeLogin {
NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:loginModelKey];
LoginModel *loginModel = [NSKeyedUnarchiver unarchiveObjectWithData:data];
return loginModel;
}
+ (void)logout {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:loginModelKey];
}//对LoginModel存储,需要使用YYModel,或者MJExtension归档,解档处理
#import "YYModel.h"
@implementation LoginModel
- (void)encodeWithCoder:(NSCoder *)aCoder {
[self yy_modelEncodeWithCoder:aCoder];
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
self = [super init];
return [self yy_modelInitWithCoder:aDecoder];
}
@end

4070

被折叠的 条评论
为什么被折叠?



