3
好吧我一直在调试整个一天,但无法弄清楚我的代码有什么问题。RestKit请求似乎只能工作一次
目标是用一个用户名/密码发送带有RestKit的POST到Heroku API以检索API密钥。
问题是我只能发送一次请求。第二次发送请求时发生错误。 (所以第一次我得到绑定到我的对象的API密钥,但第二次只是一个错误)
我使用当前版本RestKit(0.10)
代码:
- (void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
}
- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObject:(id)object
{
Account *account = (Account *)object;
NSLog(@"API_KEY: %@", account.apiKey);
}
- (IBAction) login:(id)sender
{
Account *account = [[Account alloc] init];
account.email = [emailField text];
account.password = [passwordField text];
[[RKObjectManager sharedManager] postObject:account delegate:self];
}
LOG
/// ---> FIRST CLICK
2012-05-25 14:57:00.028 HerokuApp[11154:fb03] API_KEY: 1234567890
/// ---> SECOND CLICK
2012-05-25 14:57:03.427 HerokuApp[11154:fb03] W restkit.network:RKObjectLoader.m:281 Unable to find parser for MIME Type 'text/html'
2012-05-25 14:57:03.427 HerokuApp[11154:fb03] W restkit.network:RKObjectLoader.m:309 Encountered unexpected response with status code: 200 (MIME Type: text/html -> URL: https://api.heroku.com/login -- https://api.heroku.com -- https://api.heroku.com -- https://api.heroku.com)
2012-05-25 14:57:03.429 HerokuApp[11154:fb03] didFailWithError: Error Domain=org.restkit.RestKit.ErrorDomain Code=4 "The operation couldn’t be completed. (org.restkit.RestKit.ErrorDomain error 4.)"
任何人可以帮助我解释为什么这种行为是通讯中断环?
打印出错描述可能会有帮助。 'NSLog(@“didFailWithError:%@”,错误);' – Kreiri
@Kreiri用新的日志输出更新了我的帖子 –