didLoadResponse never getting called (Basic Tutorial)

139 views
Skip to first unread message

Mike

unread,
May 17, 2011, 8:08:05 PM5/17/11
to RestKit
I've walked through the Xcode4 setup from README.md and I think I've
followed the basic tutorial but my delegate callback never seems to be
getting called after sending out a request. Neither didLoadResponse
or didFailLoadWithError ever get called, the isNetworkAvailable call
returns true. Watching the apache request log on the
secure.blahz.info server no request ever comes through.

I'm running this on the iPad simulator targeting for 4.3 any
suggestions would be greatly appreciated.

Thanks


SplunkRequestor.h:
//
// SplunkRequestor.h
// SplunkPad
//
// Created by Mike Roest on 11-04-20.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>

#import <RestKit/RestKit.h>


@interface SplunkRequestor : NSObject <RKRequestDelegate>{
}
-(void) sendLoginRequest;
-(void)request:(RKRequest*)request didLoadResponse:
(RKResponse*)response;
- (void)request:(RKRequest *)request didFailLoadWithError:(NSError
*)error;
- (void)requestDidStartLoad:(RKRequest *)request;
@property (nonatomic,retain) NSString* lastResponse;
@property (nonatomic) BOOL responseComplete;
@end

SplunkRequestor.m:

//
// SplunkRequestor.m
// SplunkPad
//
// Created by Mike Roest on 11-04-20.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "SplunkRequestor.h"

@implementation SplunkRequestor

@synthesize lastResponse;

@synthesize responseComplete;

-(void) sendLoginRequest {

RKClient* client = [RKClient clientWithBaseURL:@"https://
secure.blahz.info"];
NSLog(@"%@",[client baseURL]);

if([client isNetworkAvailable])
NSLog(@"%@",@"is available");



[client get:@"/index.html" delegate:self];
}
- (void)requestDidStartLoad:(RKRequest *)request {

NSLog(@"%@","started Loading");
}
-(void)request:(RKRequest*)request didLoadResponse:
(RKResponse*)response {
if([request isGET]) {
if([response isOK])
self.lastResponse = [response bodyAsString];
else
self.lastResponse = [response failureErrorDescription];

self.responseComplete = [response isOK];
}
}

- (void)request:(RKRequest *)request didFailLoadWithError:(NSError
*)error {
self.responseComplete = true;
self.lastResponse = [error localizedDescription];
}

@end

Mike Roest

unread,
May 17, 2011, 8:11:36 PM5/17/11
to RestKit
Pastebin formatted version of the source since the Groups form messed the formatting.


SplunkRequestor.m: http://pastebin.com/0iXKTpFg
SplunkRequestor.h: http://pastebin.com/Z0721V8u

Blake Watters

unread,
May 17, 2011, 10:12:56 PM5/17/11
to res...@googlegroups.com
Hi Mike -

I suspect that your request is being held in limbo on the request queue. Try letting the run-loop cycle before sending the request:

[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.3]];

The reachability support works by installing itself into the run-loop. I am guessing that your request is failing to send because of indeterminate or unavailable network connectivity and there's a bug around delegate invocation. You also may want to trace its path through RKRequestQueue to see where its going wrong. 

I've opened up an issue on Github for this, if you find a root cause please update the issue or even better, shoot us a patch: https://github.com/twotoasters/RestKit/issues/113

- Blake
Blake Watters
Two Toasters | CTO
Reply all
Reply to author
Forward
0 new messages