UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"确定要退出吗?" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[LCProgressHUD showLoading:@"正在退出...."];
[NSTimer scheduledTimerWithTimeInterval:TIME
target:self
selector:@selector(getOutID)
userInfo:nil
repeats:NO];
}];
[alertController addAction:cancelAction];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
}
-(void)getOutID{
//获取UserDefaults单例
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
//移除UserDefaults中存储的用户信息
[userDefaults removeObjectForKey:@"name"];
[userDefaults removeObjectForKey:@"MessageNum"];
//[userDefaults removeObjectForKey:@"password"];
[userDefaults synchronize];
[LCProgressHUD showMessage:@"退出成功"];
}