I have been working on networking my ios app. I need to call a php file on my website and then get information back. I have been using this tutorial but it is out of date and unsupported now.
http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service
I have been looking at the MKNetworkKit for a bit and i think that is what i need to use but i am not sure how to implement it.
I think most people agree that AFNetworking is the best suited library for this. There's even a really nice raywenderlich.com tutorial on how to use it.
For instance, I use it this way to get the contents of a link with parameters (makemyday.com/web/export.php?id=345) into a UIWebView
:
- (IBAction)searchForNearbyButtonPressed:(id)sender {
NSURL *baseURL = [NSURL URLWithString:@"http://makemyday.com"];
NSDictionary *parameters = @{@"id": @"345"};
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
[client registerHTTPOperationClass:[AFHTTPRequestOperation class]];
[client getPath:@"/web/export.php"
parameters:parameters
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"response=%@", [operation.response allHeaderFields]);
[self.webView loadData:responseObject MIMEType:operation.response.MIMEType textEncodingName:operation.response.textEncodingName baseURL:operation.response.URL];
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error=%@", error.description);
}
];
}