commit | author | age
|
bf3f86
|
1 |
// WkWebView+AFNetworking.h |
633752
|
2 |
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) |
6e1425
|
3 |
// |
H |
4 |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
5 |
// of this software and associated documentation files (the "Software"), to deal |
|
6 |
// in the Software without restriction, including without limitation the rights |
|
7 |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
8 |
// copies of the Software, and to permit persons to whom the Software is |
|
9 |
// furnished to do so, subject to the following conditions: |
|
10 |
// |
|
11 |
// The above copyright notice and this permission notice shall be included in |
|
12 |
// all copies or substantial portions of the Software. |
|
13 |
// |
|
14 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
15 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
16 |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
17 |
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
18 |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
19 |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
20 |
// THE SOFTWARE. |
|
21 |
|
|
22 |
#import <Foundation/Foundation.h> |
|
23 |
|
633752
|
24 |
#import <TargetConditionals.h> |
6e1425
|
25 |
|
633752
|
26 |
#if TARGET_OS_IOS |
6e1425
|
27 |
|
H |
28 |
#import <UIKit/UIKit.h> |
bf3f86
|
29 |
#import <WebKit/WebKit.h> |
6e1425
|
30 |
|
H |
31 |
NS_ASSUME_NONNULL_BEGIN |
|
32 |
|
633752
|
33 |
@class AFHTTPSessionManager; |
6e1425
|
34 |
|
bf3f86
|
35 |
@interface WKWebView (AFNetworking) |
6e1425
|
36 |
|
H |
37 |
/** |
bf3f86
|
38 |
The session manager used to download all request |
6e1425
|
39 |
*/ |
633752
|
40 |
@property (nonatomic, strong) AFHTTPSessionManager *sessionManager; |
6e1425
|
41 |
|
H |
42 |
/** |
|
43 |
Asynchronously loads the specified request. |
bf3f86
|
44 |
|
6e1425
|
45 |
@param request A URL request identifying the location of the content to load. This must not be `nil`. |
bf3f86
|
46 |
@param navigation The WKNavigation object that containts information for tracking the loading progress of a webpage. This must not be `nil`. |
633752
|
47 |
@param progress A progress object monitoring the current download progress. |
6e1425
|
48 |
@param 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. |
633752
|
49 |
@param 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. |
6e1425
|
50 |
*/ |
H |
51 |
- (void)loadRequest:(NSURLRequest *)request |
bf3f86
|
52 |
navigation:(WKNavigation * _Nonnull)navigation |
633752
|
53 |
progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress |
6e1425
|
54 |
success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success |
H |
55 |
failure:(nullable void (^)(NSError *error))failure; |
|
56 |
|
|
57 |
/** |
|
58 |
Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. |
bf3f86
|
59 |
|
6e1425
|
60 |
@param request A URL request identifying the location of the content to load. This must not be `nil`. |
bf3f86
|
61 |
@param navigation The WKNavigation object that containts information for tracking the loading progress of a webpage. This must not be `nil`. |
6e1425
|
62 |
@param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. |
H |
63 |
@param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. |
bf3f86
|
64 |
@param progress A progress object monitoring the current download progress. |
6e1425
|
65 |
@param 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. |
633752
|
66 |
@param 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. |
6e1425
|
67 |
*/ |
H |
68 |
- (void)loadRequest:(NSURLRequest *)request |
bf3f86
|
69 |
navigation:(WKNavigation * _Nonnull)navigation |
6e1425
|
70 |
MIMEType:(nullable NSString *)MIMEType |
H |
71 |
textEncodingName:(nullable NSString *)textEncodingName |
633752
|
72 |
progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress |
6e1425
|
73 |
success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success |
H |
74 |
failure:(nullable void (^)(NSError *error))failure; |
|
75 |
|
|
76 |
@end |
|
77 |
|
|
78 |
NS_ASSUME_NONNULL_END |
|
79 |
|
|
80 |
#endif |