+ (User *) shareInstance{
staticdispatch_once_t once;
static User * instance;
dispatch_once(&once, ^{
instance = [Usernew];
});
return instance;
}
登出,使用系统方法
#define UserDefaultNickname @"nickname"
#define UserDefaultPassword @"password"
#define UserDefaultPhoneNum @"phonenum"
+ (void) logOut{
//删除本地存储
NSUserDefaults *userDefaults = [NSUserDefaultsstandardUserDefaults];
[userDefaultsremoveObjectForKey:UserDefaultPassword];
[userDefaultsremoveObjectForKey:UserDefaultPhoneNum];
[userDefaultssynchronize];//修改立即同步
//云信登出
[[[NIMSDKsharedSDK] loginManager]logout:nil];
}
登入存储信息到本地,方便自动登入
//将登陆信息存储到本地
//系统方法
NSUserDefaults *accountDefaults = [NSUserDefaultsstandardUserDefaults];
[accountDefaultssetObject:pwd forKey:UserDefaultPassword];
[accountDefaultssetObject:telNumStr forKey:UserDefaultPhoneNum];
读取本地存储NSUserDefaults *accountDefaults = [NSUserDefaultsstandardUserDefaults];
NSString *phonenum = [accountDefaultsobjectForKey:UserDefaultPhoneNum];
NSString *password = [accountDefaultsobjectForKey:UserDefaultPassword];
[SVProgressHUD show];//缓冲圈
//异步开启线程,主线程执行缓冲圈
/*[SVProgressHUD show];
//开启异步线程
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[T4HttpHelper connectAPIPath:MemberCenterLogin submitParam:@{}
httpMethod:Get successBlock:^(NSDictionary *responseDic) {
//切换到主线程
dispatch_async(dispatch_get_main_queue(), ^{
[SVProgressHUD dismiss];
// write your codes here
});
} errorBlock:^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[SVProgressHUD dismiss];
// write your codes here
});
}];
});*/