プログラムでアプリケーションを終了するより良い方法はありますか?
最近、アプリプロセスを終了するために 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]; メソッド
アプリを終了する、または少なくともアプリのプロセスをフリーズするための他のより良い方法..助けが必要ですか?