-(void)getTimeout{
NSString *nowtime = [NSString getNowTimeTimestamp];
NSString *oldtime =[[NSString alloc] init];
if (USERDEFAULT_object(@"TimestampBX")) {
oldtime = USERDEFAULT_object(@"TimestampBX");
}else{
oldtime = [NSString getNowTimeTimestamp];
}
NSInteger integer1 = [nowtime integerValue];
NSInteger integer2 = [oldtime integerValue];
if (((integer1 -integer2)/3600)>= 24) {
BXLog(@"退出登陆");
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSDictionary *dic = [userDefaults dictionaryRepresentation];
for (id key in dic) {
if ([key isEqualToString:@"isFirst"] || [key isEqualToString:@"getNowTimeTimestamp"]) {
continue;
}
[userDefaults removeObjectForKey:key];
}
[userDefaults synchronize];
[[NSNotificationCenter defaultCenter] postNotificationName:@"loginNotcenter" object:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//改变根视图
[SVProgressHUD showImage:GetImage(@"BXImage") status:@"登录失效,请重新登录"];
SVHUDdisDelay2;
});
return ;
}else{
BXLog(@"不退出登陆");
}
}
网友评论