美文网首页
项目时间比较

项目时间比较

作者: iOS开发小学生 | 来源:发表于2018-12-25 15:45 被阅读9次
    -(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(@"不退出登陆");
        }
    
    }
    
    

    相关文章

      网友评论

          本文标题:项目时间比较

          本文链接:https://www.haomeiwen.com/subject/rymflqtx.html