0
votes

I am currently using MKNetworkKit to cache the download of several images from a restful server. I have another restful service I ping to get supplemental information about the images. Whichever server I ping first works, but when pinging the second server I get the following error:

[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 is pinging the first server in attempt to get data from the second server's URL. I think I may need to create another reachability object? Any idea what I'm doing wrong? Or where I can find some example implementation of one project with multiple subclasses?

Edit I implement both engines the following way:

@implementation FirstEngine

FirstEngine* _sharedEngine;

+(FirstEngine*)sharedEngine
{
    if(_sharedEngine==nil)
    {
        _sharedEngine = [[FirstEngine alloc] initWithHostName:@"***.**.**.**" customHeaderFields:nil];            
    }
    return _sharedEngine;
}

and invoke them this way:

$[[FirstEngine sharedEngine] bodyForPath:url verb:verb body:params onCompletion:^(NSDictionary* body)
{}....

or

$[[SecondEngine sharedEngine] bodyForPath:url verb:verb body:params onCompletion:^(NSDictionary* body)
{}....
1

1 Answers

1
votes

You should create a MKNetworkEngine object in your AppDelegate for "every" server you talk to.

self.imageCacheEngine = [[MKNetworkEngine alloc] initWithHostName:@"images.myserver.com"];

and

self.apiEngine =  [[MKNetworkEngine alloc] initWithHostName:@"api.myserver.com"];

Enqueue image requests to the imageCacheEngine and api requests to your apiEngine.