を使用して、さまざまなエラー状態の NSNotificationCenterを送信および受信できます。NSNotification
serviceproxybase関心のあるオブザーバーに通知を投稿します。
[[NSNotificationCenter defaultCenter] postNotificationName:@"NoConnectionNotification" object:nil userInfo:someErrorInfoObject];
通常、オブジェクト、失敗したサービス リクエスト、またはサービスのエラー コードsomeErrorInfoObjectなど、いくつかの追加の詳細をオブザーバーに提供するオブジェクトをパッケージ化します。View Controller では、 orNSErrorでその通知をリッスンします。viewDidLoadviewWillAppear
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleNoConnectionError:)
name:@"NoConnectionNotification"
object:nil];
これで、名前の通知が投稿されるたびに、View Controller は対応するNoConnectionNotificationへのメッセージを受け取ります。handleNoConnectionError:NSNotification