I’m really stumped by this problem. I’m using Restkit to access a web service. Most of the operations are working fine, but the first two, intializeDevice and insertNewPatron, are not. For these, the asynchronous request is fired, but the delegate methods are never called. I have checked on the server, and there is no evidence of these calls being made. I can’t tell what’s different about these operations that makes them not work. Here is the class that makes the calls:
-(id)initForController:(UIViewController *)viewController{
self.vc=viewController;
NSString *baseURL = @"https://xxxxxxxxx/APNS_WebService/rest/operations/";
NSURL *url=[NSURL URLWithString:baseURL];
client = [RKClient clientWithBaseURL:url];
client.disableCertificateValidation=YES;
return self;
}
-(void)insertNewPatronWithCard:(NSString *)cardNumber PIN:(NSString *)pin NickName:(NSString *)nickname Device:(NSString *)deviceID{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/insertNewPatron?cardNumber=%@&pin=%@&nickname=%@&deviceID=%@",cardNumber,pin,nickname,deviceID]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"insertNewPatron" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request sendAsynchronously];
}
-(void)initializeDeviceWithID:(NSString *)deviceID{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/initializeDevice?deviceID=%@",deviceID]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"initializeDevice" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request sendAsynchronously];
}
-(void)updateDevicePreferencesWithDeviceID:(NSString *)deviceID DueDateNotice:(NSString *)dueDateNotice HoldsNotice:(NSString *)holdsNotice EventNotice:(NSString *)eventNotice{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/updateDevicePreferences?deviceID=%@&dueDateNotice=%@&holdsNotice=%@&eventNotice=%@",deviceID,dueDateNotice,holdsNotice,eventNotice]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"updateDevicePreferences" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request sendAsynchronously];
}
-(void)removeUserWithCard:(NSString *)cardNumber{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/removeUser?cardNumber=%@",cardNumber]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"removeUser" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request sendAsynchronously];
}
-(void)addEventWithDevice:(NSString *)deviceID EventID:(NSString *)eventID{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/addEvent?deviceID=%@&eventID=%@",deviceID,eventID]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"addEvent" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request send];
}
-(void)removeEventWithDevice:(NSString *)deviceID EventID:(NSString *)eventID{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/removeEvent?deviceID=%@&eventID=%@",deviceID,eventID]];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"removeEvent" forKey:@"operation"];
request.params=params;
request.delegate=self;
[request sendAsynchronously];
}
-(void)removeAllEventsWithDevice:(NSString *)deviceID{
request = [client requestWithResourcePath:[NSString stringWithFormat:@"/removeAllEvents?deviceID=%@",deviceID]];
request.delegate=self;
NSDictionary *params = [NSDictionary dictionaryWithObject:@"removeAllEvents" forKey:@"operation"];
request.params=params;
[request sendAsynchronously];
}
I notice that for the operations that don’t work, in the Restkit logging, I get the message that says “Prepared GET UrlRequest”, but NOT the one that says “Proceeding with request,” which I see for the operations that work.
Did you check with a breakpoint that all the variables are correct? No nil delegate or something that you are missing? Are you doing the requests isolated or maybe one is being made at the same time as another call?
Is probable that one of your calls is loosing the delegate in the process. I recommend to use blocks instead of delegate paradigm for async request to avoid race conditions.
Hope it helps!