NSURLRequest data request

Chinese document 



1. Create and return a URL request, pointing to a specified URL, using the default caching strategy and timeout response time.

+ (id)requestWithURL:(NSURL *)theURL

Discussion

The default cache policy is NSURLRequestUseProtocolCachePolicy and the default timeout interval is 60 seconds.

The default cache policy is NSURLRequestUseProtocolCachePolicy, and the default timeout period is 60 seconds.

2.requestWithURL:cachePolicy:timeoutInterval:

Creates and returns an initialized URL request with specified values.

Create and return an initial URL request, using the specified caching strategy and timeout period.

+ (id)requestWithURL:(NSURL *)theURL cachePolicy:(NSURLRequestCachePolicy)cachePolicytimeoutInterval:(NSTimeInterval)timeoutInterval



 NSURLRequest *request = [NSURLRequest requestWithURL:htmlurl];

    // Put the requested url data into the NSData object

    NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];

    

    NSString *str = [[NSString allocinitWithData:response encoding:NSUTF8StringEncoding];


Guess you like

Origin blog.csdn.net/qq_27740983/article/details/50327467