Reputation: 761
I'm using Xcode to build my first iPhone app. Basically, I want to track my GPS location and based on that, get data from a web service. Then I want to display that data. Actually, I want to have a robot speak the data, but one issue at a time.
I found this thread:
https://stackoverflow.com/a/1791658/400732
which points to a great example from Apple, that shows how to track the location. So, how do I now call out to the web service? The less Objective-C, the better, because I'm really a Python, Javascript programmer.
Upvotes: 0
Views: 1710
Reputation: 9453
To post data and recive responses use ASIFormDataRequest
NSURL *url = [NSURL URLWithString:@"http://yourwebsite.com"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"x_coordinate" forKey:@"x"];
[request setPostValue:@"y_coordinate" forKey:@"y"];
[request startSynchronous];
NSError *error = [request error];
if (!error && [request responseStatusCode] == 200) {
NSLog(@"This is the response from the server: %@",[request responseString]];
}else{
NSLog(@"Error - Data download error: \"%@\"",[[request error] localizedDescription]);
}
Upvotes: 1