中文字幕日韩精品一区二区免费_精品一区二区三区国产精品无卡在_国精品无码专区一区二区三区_国产αv三级中文在线

iOS密碼在進入后臺1小時后重新設置-創(chuàng)新互聯(lián)

廢話不多說了,直接給大家貼代碼了,具體代碼如下所示:

創(chuàng)新互聯(lián)公司是一家專注于成都網(wǎng)站建設、成都網(wǎng)站制作與策劃設計,薊州網(wǎng)站建設哪家好?創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設10多年,網(wǎng)設計領域的專業(yè)建站公司;建站業(yè)務涵蓋:薊州等地區(qū)。薊州做網(wǎng)站價格咨詢:028-86922220

AppDelegate.m

#import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // Override point for customization after application launch.
  //當程序在后臺停留超過60分的時候,密碼會置為空。
  //1小時后將密碼重新設置
  [self timeInterval];
  return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
  // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
  // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
  //計算時間差
  [self backTime];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
  //1小時后將密碼重新設置
  [self timeInterval];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
  // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
  //計算時間差
  [self backTime];
}
#pragma -mark -密碼保存1個小時
//計算時間差
- (void)timeInterval
{
  NSLog(@"---timeInterval----");
  //設置一個字符串的時間
  NSString * dateBackString = [[NSUserDefaults standardUserDefaults] objectForKey:@"backGroundTime"];
  NSLog(@"---dateBackString---%@",dateBackString);
  if ([dateBackString isEqual:[NSNull null]] || dateBackString==nil || dateBackString.length ==0) {
  }
  else
  {
    NSInteger time = [self getTimeInterval:dateBackString];
    if (time >= 60) {
      //1小時后將密碼清空
      NSUserDefaults *userInfoDefault=[NSUserDefaults standardUserDefaults];
      [userInfoDefault setObject:@"" forKey:@"login-password"];
      [userInfoDefault synchronize];
    }
  }
}
//1小時后將密碼重新設置
- (void)backTime
{
  NSLog(@"----backTime-----");
  //計算上報時間差
  NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  //結(jié)束時間
  NSDate * currentdate = [NSDate date];
  NSString * currentDateString = [dateFormatter stringFromDate: currentdate];
  NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
  [userDefaults setObject:currentDateString forKey:@"backGroundTime"];
  [userDefaults synchronize];
}
//計算時間差
- (NSInteger)getTimeInterval:(NSString *)sendDateString
{
  NSInteger minute;
  if (sendDateString ==nil||sendDateString.length==0) {
  }
  else
  {
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    //結(jié)束時間
    NSDate * currentdate = [NSDate date];
    NSDate * currentDate = [dateFormatter dateFromString:[dateFormatter stringFromDate: currentdate]];
    NSDate * endDate = [dateFormatter dateFromString:sendDateString];
    //得到時間差
    NSTimeInterval time = [currentDate timeIntervalSinceDate:endDate];
    //    int days = ((int)time)/(3600*24);
    //    int hours = ((int)time)%(3600*24)/3600;
    //    minute = ((NSInteger)time)%(3600*24)/3600/60;
    minute = (NSInteger)time;
  }
  return minute;
}
@end

另外有需要云服務器可以了解下創(chuàng)新互聯(lián)建站www.rwnh.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

標題名稱:iOS密碼在進入后臺1小時后重新設置-創(chuàng)新互聯(lián)
文章分享:http://www.rwnh.cn/article32/dhhopc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、自適應網(wǎng)站、面包屑導航移動網(wǎng)站建設、網(wǎng)站改版、用戶體驗

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司
美姑县| 巫溪县| 抚顺市| 诏安县| 江阴市| 开化县| 务川| 麻城市| 会泽县| 汤阴县| 崇左市| 泸州市| 平湖市| 兰州市| 二手房| 司法| 邻水| 托里县| 克什克腾旗| 红河县| 政和县| 中阳县| 昌乐县| 和林格尔县| 镇原县| 马山县| 吴堡县| 桐庐县| 西平县| 鹤壁市| 交城县| 台南县| 淮阳县| 青田县| 赫章县| 运城市| 博罗县| 庆安县| 秦皇岛市| 大兴区| 涟源市|