2012-06-01 3 views
3

하나를 호출하지 냉동 작업/onCompletion &의 OnError의 추적 상태는 자동 수 있습니다 (예 : 서버에 업로드 등) HTTP POST 요청을 "동결"만드는 방법을 쉽게 나중에 네트워크 연결이 복원되면 다시 시작됩니다. 여기MKNetworkKit - MKNetworkKit 라이브러리의 많은 훌륭한 기능

세부 사항 : http://blog.mugunthkumar.com/products/ios-framework-introducing-mknetworkkit/#Operation_freezing

하지만 내 MKNetworkKit 기반 응용 프로그램을 마무리하고있어, 나는이 발견 한 그 onCompletion와의 OnError 블록이 고정 된 네트워크 트랜잭션에서 호출되지 않는다 (이 분명히 알려져있다 문제), 그리고 고정 된 트랜잭션이 실제로 완료 될 때 사용자에게 알릴 수있는 UI를 빌드하는 방법에 어려움을 겪고 있습니다.

이 상황을 처리 한 사람이 있습니까?

네트워크 방울 다운 타임을 잊기 사용자를 유지하는 가장 좋은 방법은,하지만 여전히 다음 마지막으로 성공한 연결이 때 주위에 몇 가지 피드백을 제공 할 수 있도록 무엇입니까?

답변

4

내가 생각 해낸 가장 좋은 대답은 MKNetworkOperation을 하위 클래스, 그리고 다음 operationSucceeded 및 operationFailedWithError를 오버라이드 (override) 할 수 있습니다. 이러한 루틴은 고정 된 작업이 완료 될 때까지 계속 호출됩니다.

/*! 
* @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; 
다음 MKNetworkOperation.h 헤더 파일에서

관련 문제