3

MKNetworkKit ライブラリの多くの優れた機能の 1 つは、後でネットワーク接続が復元されたときに自動再開できる http POST 要求 (サーバーへのアップロードなど) を簡単に「凍結」できることです。

詳細はこちら: http://blog.mugunthkumar.com/products/ios-framework-introducing-mknetworkkit/#Operation_freezing

しかし、MKNetworkKit ベースのアプリを完成させているときに、凍結されたネットワーク トランザクションで onCompletion ブロックと onError ブロックが呼び出されないことがわかりました (これは明らかに既知の問題です)。これにより、凍結されたトランザクションが実際にいつ完了するかをユーザーに知らせることができます。

誰かがこの状況に対処しましたか?

ユーザーがネットワークのドロップやダウンタイムに気付かないようにするための最善の方法は何ですか?

4

1 に答える 1

4

私が思いついた最良の答えは、MKNetworkOperation をサブクラス化し、次に operationSucceeded と operationFailedWithError をオーバーライドすることでした。これらのルーチンは、凍結された操作が完了したときにも呼び出されます。

MKNetworkOperation.h ヘッダー ファイルから:

/*!
 *  @abstract Overridable custom method where you can add your custom business logic error handling
 *  
 *  @discussion
 *  This optional method can be overridden to do custom error handling. Be sure to call [super operationSucceeded] at the last.
 *  For example, a valid HTTP response (200) like "Item not found in database" might have a custom business error code
 *  You can override this method and called [super failWithError:customError]; to notify that HTTP call was successful but the method
 *  ended as a failed call
 *
 */
-(void) operationSucceeded;

/*!
 *  @abstract Overridable custom method where you can add your custom business logic error handling
 *  
 *  @discussion
 *  This optional method can be overridden to do custom error handling. Be sure to call [super operationSucceeded] at the last.
 *  For example, a invalid HTTP response (401) like "Unauthorized" might be a valid case in your app.
 *  You can override this method and called [super operationSucceeded]; to notify that HTTP call failed but the method
 *  ended as a success call. For example, Facebook login failed, but to your business implementation, it's not a problem as you
 *  are going to try alternative login mechanisms.
 *
 */
-(void) operationFailedWithError:(NSError*) error;
于 2012-07-17T00:58:55.190 に答える