我使用RESTKIT對象管理器從我的服務器的信息超時間隔。我的實現代碼片段如下:如何設置RESTKIT對象管理
-(void)getObjects
{
//Instantiate the RestKit Object Manager
RKObjectManager *sharedManager = [RKObjectManager sharedManager];
//show the spinner
[self showLoading];
//call server with the resourcepath
[sharedManager loadObjectsAtResourcePath:self.resourcePath delegate:self];
}
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects
{
// handling in scenarios of empty arrays
if ([objects count]==0){
[self hideLoading];
if (emptyHandler){
emptyHandler();
}else{
[self standardEmptyHandling];
}
return;
}
// planned failure
if ([[objects objectAtIndex:0] isKindOfClass:[Failure class]]){
NSAssert([objects count]==1,@"object returned is type failure, but there are more than one object in it");
failureObject=[objects objectAtIndex:0];
[self hideLoading];
[self standardErrorHandling];
return;
}
//return completion block to caller
completionHandler(objects);
}
但是可能存在這樣的情況,其中有終止(微調將顯示前一個服務器錯誤或可達性錯誤這導致進程繼續嘗試很長一段時間擴展量time_的。
有沒有辦法在我的實現設置超時時間,這樣我可以提示用戶的警報再次嘗試,如果服務器沒有在20秒例如應對?
做你嘗試設置'RKRequestQueue requestTimeout'財產? – mja
@mja nope我沒有。我應該在哪裏設置這個屬性?在我的getObjects方法?你能告訴我如何在我目前的實踐中設定這一點嗎? – Zhen
剛發現這個 - 猜測它還沒有實現。 https://github.com/RestKit/RestKit/issues/228 – mja