I’m using the ASIHTTPRequest class for make some web services with my iPhone app. Here are some sample code I use for that
-(void)startRequest {
NSURL *url = [NSURL URLWithString:@"www.myURL/iOS/objc.php"];
//NSURL *url = [NSURL URLWithString:@"http://localhost:8888/API/objc.php"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];
[request setPostValue:@"1" forKey:@"getWines"];
[request startAsynchronous];
}
and obviously I catch the result in this function :
- (void)requestFinished:(ASIHTTPRequest *)request {
NSString *result = request.responseString;
}
When I launch the simulator with the localhost URL
NSURL *url = [NSURL URLWithString:@"http://localhost:8888/API/objc.php"];
My app works good. But when I
- Launch with my device
- Launch with the simulator to the server location
Nothing happens! I mean, the requestFinished is never called!
If I try with Google Chrome I got some answer, but with both of condition above nothing.
I finally found what was wrong with, this is because I wrote
“www.myURL/iOS/objc.php”
Instead of
“http://www.myURL/iOS/objc.php”,
change everythings !