Reputation:
I'm testing iphone application via xCode both simulation and on iphone device. On the simulation, there is no problem, but when running on the iphone device, NSURLConnection fails, connection:didFailWithError: method called.
What can be the reason for this problem?
Upvotes: 1
Views: 2557
Reputation: 4557
When you use the phone it is connecting through the phone's internet connection. When on the simulator it uses your computer's internet connection.
If there is a problem it is probably with the connection on the phone to whatever your connecting to. Maybe what ever your connecting to is blocking your phone? It's probably not a problem with the application if it works on the simulator.
Upvotes: 0
Reputation: 4561
Find out by inspecting the NSError object that you receive in connection:didFailWithError:. See listing 3 over at the Using NSUrlConnection documentation:
- (void)connection:(NSURLConnection *)connection
didFailWithError:(NSError *)error
{
[connection release];
[receivedData release];
NSLog(@"Connection failed! Error - %@ %@",
[error localizedDescription],
[[error userInfo] objectForKey:NSErrorFailingURLStringKey]);
}
Upvotes: 2