Make your WKWebView happy with NSURLProtocol
Clone or download
Latest commit 61eb421 Sep 28, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
NSURLProtocol+WebKitSupport.xcodeproj Add files. Oct 11, 2016
NSURLProtocol+WebKitSupport Add files. Oct 11, 2016
Source Use KVC instead of NSClassFromString. This may reduce the possibility… Oct 11, 2016
.gitignore Add files. Oct 11, 2016
LICENSE Initial commit Oct 11, 2016
README.md Update README.md Sep 28, 2017
snapshot.gif Make snapshot smaller Oct 11, 2016

README.md

NSURLProtocol+WebKitSupport

Note:If you target iOS 11, you can now use WKURLSchemeHandler to avoid this trick! 😆

让 WKWebView 支持 NSURLProtocol

This example project shows a way to use NSURLProtocol with WKWebView, which was not possible before.

Screenshot

Usage

Drag NSURLProtocol+WebKitSupport.h and NSURLProtocol+WebKitSupport.m into your project, then register the scheme for NSURLProtocol to handle:

[NSURLProtocol wk_registerScheme:@"https"];

// You can now use your own NSURLProtocol subclasses as before.
[NSURLProtocol registerClass:[MyAwesomeURLProtocol class]];

To remove the scheme from registery:

[NSURLProtocol wk_unregisterScheme:@"https"];

Note

This category uses undocumented APIs in WebKit. Use at your own risk.