【发布时间】:2013-09-02 20:25:17
【问题描述】:
我有一个 iOS 应用程序从我的 Rails 3 应用程序请求 JSON 数据,托管在 Heroku 上,它在我的设备和许多其他用户上运行良好,除了一个。我有一个用户告诉我,我的应用程序无法检索 JSON 数据,所以我让她给我发送了一些日志数据,日志显示 NSURLConnection 委托方法 didFailWithError 正在被调用,错误描述为 “错误网址”。为什么会出现这个错误?为什么它只出现在某些设备上而不是所有设备上?
这是我的代码,
-(void)getTournamentInfoWithUsername:(NSString*)username
{
NSString *urlString = [NSString stringWithFormat:@"http://myapp-tourney.heroku.com/tournaments/next.json?username=%@", username];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30];
[self setUrlConnection:[[NSURLConnection alloc] initWithRequest:request delegate:self]];
}
- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
{
[MyLog logError:[NSString stringWithFormat:@"%@ - %@ - %@ - %@", [error localizedDescription], [error localizedFailureReason], [error localizedRecoveryOptions], [error localizedRecoverySuggestion]]];
}
日志显示...
bad URL - (null) - (null) - (null)
非常感谢您的智慧!
【问题讨论】:
-
遇到崩溃/故障的用户名是否可疑?
-
查看我的答案以获得更详细的答案:stackoverflow.com/questions/6287230/…
标签: iphone ios ipad nsurlconnection