我目前正在使用MKNetworkKit緩存來自寧靜服務器的多個圖像的下載。我還有另一項寧靜的服務,可以獲取關於圖像的補充信息。無論服務器我先PING工作,但查驗第二個服務器我收到以下錯誤時:如何擁有MKNetworkKit的多個子類?
[The operation couldn’t be completed. (NSURLErrorDomain error 404.)] 2012-08-12 19:51:12.340 [51853:11603]
Error: Error Domain=NSURLErrorDomain Code=404 "The operation couldn’t be completed. (NSURLErrorDomain error 404.)" UserInfo=0x73c5490 {Server=Apache-Coyote/1.1, Content-Length=47, Content-Type=text/html;charset=ISO-8859-1, Connection=keep-alive, Date=Sun, 12 Aug 2012 23:51:11 GMT} 2012-08-12 19:51:12.341 [MKNetworkOperation operationFailedWithError:] [Line 1280] State: 0
MKNetworkKit在強制的第一臺服務器在嘗試從第二個服務器的URL獲取數據。我想我可能需要創建另一個可達性對象?任何想法我做錯了什麼?或者我可以在其中找到一個具有多個子類的項目的示例實現?
編輯 我實現這兩個引擎的方式如下:
@implementation FirstEngine
FirstEngine* _sharedEngine;
+(FirstEngine*)sharedEngine
{
if(_sharedEngine==nil)
{
_sharedEngine = [[FirstEngine alloc] initWithHostName:@"***.**.**.**" customHeaderFields:nil];
}
return _sharedEngine;
}
,並調用它們是這樣的:
$[[FirstEngine sharedEngine] bodyForPath:url verb:verb body:params onCompletion:^(NSDictionary* body)
{}....
或
$[[SecondEngine sharedEngine] bodyForPath:url verb:verb body:params onCompletion:^(NSDictionary* body)
{}....
感謝您的回覆。考慮到上面的代碼編輯,我該如何做到這一點? – 2012-08-15 18:38:34
您不應該重寫sharedEngine。在AppDelegate中創建引擎後,使用[AppDelegate.engine imageAtURL ...] – Mugunth 2012-08-17 03:53:44