Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For asynchronous fetch of HTML source code, I recommend you to use <a href="https://github.com/AFNetworking/" rel="nofollow">AFNetworking</a></p> <p>1) Then subclass AFHTTPCLient, for example:</p> <pre><code>//WebClientHelper.h #import "AFHTTPClient.h" @interface WebClientHelper : AFHTTPClient{ } +(WebClientHelper *)sharedClient; @end //WebClientHelper.m #import "WebClientHelper.h" #import "AFHTTPRequestOperation.h" NSString *const gWebBaseURL = @"http://dummyBaseURL.com/"; @implementation WebClientHelper +(WebClientHelper *)sharedClient { static WebClientHelper * _sharedClient = nil; static dispatch_once_t oncePredicate; dispatch_once(&amp;oncePredicate, ^{ _sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:gWebBaseURL]]; }); return _sharedClient; } - (id)initWithBaseURL:(NSURL *)url { self = [super initWithBaseURL:url]; if (!self) { return nil; } [self registerHTTPOperationClass:[AFHTTPRequestOperation class]]; return self; } @end </code></pre> <p>2) Request asynchronously HTML source code, put this code in any relevant part</p> <pre><code>NSString *testNewsURL = @"http://whatever.com"; NSURL *url = [NSURL URLWithString:testNewsURL]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; AFHTTPRequestOperation *operationHttp = [[WebClientHelper sharedClient] HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { NSString *szResponse = [[[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding] autorelease]; NSLog(@"Response: %@", szResponse ); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Operation Error: %@", error.localizedDescription); }]; [[WebClientHelper sharedClient] enqueueHTTPRequestOperation:operationHttp]; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload