Ios development-common network and ios development network
Directly Add code
Example:
-(Void) touchesBeGan :( NSSet *) touches withEvent :( UIEvent *) event
{
// 1.url
NSURL * url = [NSURL URLWithString: @ "http://m.baidu.com"]'
// 2. request
NSURLRequest * request = [NSURLRequest requestWithURL: url];
// 3. Send a network connection to obtain binary data
[NSURLConnection sendAsynchronouRequest: request queue: [NSOperationQueue mainQueue] completionHandler: ^ (NSURLResponse * response, NSData * data, NSError * connectionError ){
// When developing http access, the returned binary data is usually converted into a string for debugging.
NSString * html = [NSString alloc] initWithData: data encoding: NSUTF8StringEncoding
;
NSLog (@ "% @", html );
}];
}
IOS Network Development
Mobile Phone: IOS has many network frameworks, the most classic ASHTTP
AFNETWORK is recommended.
Server: depending on the language you are familiar with, the server has a web service. Your client requests this web service and returns data. The data format is often json, xml, or string.
The other is the knowledge of uikit. Since you are a standalone app, this is not a problem.
How to implement network protocols in ios development
Using ASIHttpRequest is much more convenient than the IOS native network. It is easy to get started and easy to use. Common interface access, post submission, queue requests, persistent connections, etc.