UIWebView(AFNetworking) Category Reference

UIWebView(AFNetworking) Category Reference

Declared in UIWebView+AFNetworking.h
UIWebView+AFNetworking.m

Overview

This category adds methods to the UIKit framework’s UIWebView class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling.

When using these category methods, make sure to assign delegate for the web view, which implements –webView:shouldStartLoadWithRequest:navigationType: appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that canGoBack & canGoForward update their values correctly.

  sessionManager

The session manager used to download all requests.

@property (nonatomic, strong) AFHTTPSessionManager *sessionManager

Declared In

UIWebView+AFNetworking.h

– loadRequest:progress:success:failure:

Asynchronously loads the specified request.

- (void)loadRequest:(NSURLRequest *)request progress:(NSProgress *_Nullable __autoreleasing *_Nullable)progress success:(nullable NSString *( ^ ) ( NSHTTPURLResponse *response , NSString *HTML ))success failure:(nullable void ( ^ ) ( NSError *error ))failure

Parameters

request

A URL request identifying the location of the content to load. This must not be nil.

progress

A progress object monitoring the current download progress.

success

A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string.

failure

A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.

Declared In

UIWebView+AFNetworking.h

– loadRequest:MIMEType:textEncodingName:progress:success:failure:

Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding.

- (void)loadRequest:(NSURLRequest *)request MIMEType:(nullable NSString *)MIMEType textEncodingName:(nullable NSString *)textEncodingName progress:(NSProgress *_Nullable __autoreleasing *_Nullable)progress success:(nullable NSData *( ^ ) ( NSHTTPURLResponse *response , NSData *data ))success failure:(nullable void ( ^ ) ( NSError *error ))failure

Parameters

request

A URL request identifying the location of the content to load. This must not be nil.

MIMEType

The MIME type of the content. Defaults to the content type of the response if not specified.

textEncodingName

The IANA encoding name, as in utf-8 or utf-16. Defaults to the response text encoding if not specified.

progress

A progress object monitoring the current download progress.

success

A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data.

failure

A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.

Declared In

UIWebView+AFNetworking.h

CTLog Reference
AFNetworkReachabilityStatusBlock Block Reference

AFNetworkReachabilityStatusBlock Block Reference

Declared in AFNetworkReachabilityManager.m

Block Definition

AFNetworkReachabilityStatusBlock

typedef void (^AFNetworkReachabilityStatusBlock) (AFNetworkReachabilityStatus status)
AFURLSessionDataTaskDidReceiveDataBlock Block Reference

AFURLSessionDataTaskDidReceiveDataBlock Block Reference

Declared in AFURLSessionManager.m

Block Definition

AFURLSessionDataTaskDidReceiveDataBlock

typedef void (^AFURLSessionDataTaskDidReceiveDataBlock) (NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data)
AFNetworkActivityActionBlock Block Reference

AFNetworkActivityActionBlock Block Reference

Declared in AFNetworkActivityIndicatorManager.m

Block Definition

AFNetworkActivityActionBlock

typedef void (^AFNetworkActivityActionBlock) (BOOL networkActivityIndicatorVisible)
AFURLSessionDataTaskDidBecomeDownloadTaskBlock Block Reference

AFURLSessionDataTaskDidBecomeDownloadTaskBlock Block Reference

Declared in AFURLSessionManager.m

Block Definition

AFURLSessionDataTaskDidBecomeDownloadTaskBlock

typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock) (NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask)
AFQueryStringSerializationBlock Block Reference

AFQueryStringSerializationBlock Block Reference

Declared in AFURLRequestSerialization.m

Block Definition

AFQueryStringSerializationBlock

typedef NSString* (^AFQueryStringSerializationBlock) (NSURLRequest *request, id parameters, NSError *__autoreleasing, * error)
AFURLSessionDataTaskDidReceiveResponseBlock Block Reference

AFURLSessionDataTaskDidReceiveResponseBlock Block Reference

Declared in AFURLSessionManager.m

Block Definition

AFURLSessionDataTaskDidReceiveResponseBlock

typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock) (NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response)
AFURLSessionDataTaskWillCacheResponseBlock Block Reference

AFURLSessionDataTaskWillCacheResponseBlock Block Reference

Declared in AFURLSessionManager.m

Block Definition

AFURLSessionDataTaskWillCacheResponseBlock

typedef NSCachedURLResponse* (^AFURLSessionDataTaskWillCacheResponseBlock) (NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse)