サーバーへのHTTPリクエストを作成する方法を探しているなら、これを行うのに役立ついくつかのフレームワークがあります。最近まで、 ASIHTTPRequest が私が好むものでしたが、残念ながらそれは中止されました。
Google's API Client Library is also a good option, as well as a number of others suggested by the creator of ASIHTTPRequest.
あなたを始めさせるためにそこにたくさんのドキュメントがあるはずです。
EDIT: To make your specific request with ASIHTTPRequest
, do the following in a class with the protocol ASIHTTPRequestDelegate
:
/**
* Make a request to the server.
*/
- (void) makeRequest {
//compile your URL string and make the request
NSString *requestURL = [NSString stringWithFormat:@"%@?u=%@& p=%@&platform=ios", url, txtUserName.text, txtPassword.text];
NSURL *url = [NSURL URLWithString:requestURL];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
}
/**
* Handle the response from the previous request.
* @see ASIHTTPRequestDelegate
*/
- (void) requestFinished:(ASIHTTPRequest*)request {
NSString *responseString = [request responseString];
//do whatever you need with the response, i.e.
//convert it to a JSON object using the json-framework (https://github.com/stig/json-framework/)
}