他们是否有更好的方式以编程方式退出应用程序?
最近我做了一个无线电应用程序,它有一个用户设置来设置时间,使用 NSTimer 退出应用程序进程(我的意思是睡眠时间)。当时间到达应用程序应该停止其进程并退出。
当时间到达时,我使用这些语句退出应用程序,
[[UIApplication sharedApplication] suspend];
[[UIApplication sharedApplication] terminateWithSuccess];
theTimer=[NSTimer scheduledTimerWithTimeInterval:(1.0/1.0) target:self selector:@selector(countTime) userInfo:nil repeats:YES];
counter-=1;
timeLeft.text=[NSString stringWithFormat:@" %d",counter];
if (counter==0.0) {
[theTimer invalidate];
[[UIApplication sharedApplication] suspend];
[[UIApplication sharedApplication] terminateWithSuccess];
使用 [[UIApplication sharedApplication] suspend] 有什么问题吗?[[UIApplication sharedApplication] terminateWithSuccess]; 方法
退出应用程序的任何其他更好的方法,或者至少冻结应用程序进程..我需要帮助吗?