5

iPhone アプリケーションには、次のような行を含むかなりの数の場所があります。

if (![context save:&error]) {
  /*
  Replace this implementation with code to handle the error appropriately.

  abort() causes the application to generate a crash log and terminate. 
  You should not use this function in a shipping application, although 
  it may be useful during development. If it is not possible to recover 
  from the error, display an alert panel that instructs the user to quit 
  the application by pressing the Home button.
  */

  NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
  abort();
}

実稼働アプリケーションで実際に abort() を何に置き換えるかについて、私はちょっと途方に暮れています。ユーザーのデバイスがエラーを送り返すことを許可する簡単な方法はないと思います。ここでの標準的な慣行は何ですか?

4

1 に答える 1

5

私が行ったことは、アプリケーションで何が起こっているかによって異なります。アプリケーションに影響を与えずに保存をロールバックできる場合は、それを行うことができます。それはかなり珍しいでしょう。多くの場合、保存に失敗したことをユーザーに知らせたいと思うでしょう。失敗の原因に応じて、再試行するか、無効であった理由を説明することを申し出ることができます。

基本的には、アプリケーションと、ユーザーに最適なサービスを提供する方法によって異なります。

于 2010-01-19T21:30:57.480 に答える