是他們通過編程方式退出應用程序的更好方法嗎?通過設置NSTimer退出應用程序?
最近,我提出,有一個用戶設置使用的NSTimer設定時間退出該應用處理(我的意思是睡眠時間)的無線應用。當時間到達應用程序應該停止其進程並退出。
我使用這些語句通過使用[[UIApplication的sharedApplication]暫停]當時間到達的退出程序,
[[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] terminateWithSuccess];方法
任何其他更好的方式來退出應用程序,或者至少凍結應用過程.. 我需要幫助嗎?
所以你說的是使用exit(0);不是問題,但有人說使用exit(0)不被蘋果認可! – 2012-03-16 08:17:11
我從來沒有遇到任何問題,它是由Apple API調用記錄和使用的。 – fbernardo 2012-03-16 08:33:29
所以我可以打電話像if(counter == 0.0){ exit(0); – 2012-03-16 09:25:31