Ios development-common network and ios development network

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.