-4

I'm trying to figure out how URLProtocol works. Can you provide some cases of URLProtocol usage? What type of problems can it solve?

Zouhair Sassi
  • 1,403
  • 1
  • 13
  • 30
Alex Yapryntsev
  • 589
  • 6
  • 19
  • 1
    This article and demo might help you: https://www.raywenderlich.com/2292-using-nsurlprotocol-with-swift – Hima Aug 08 '19 at 13:21

1 Answers1

2

URLProtocol allows you to insert yourself into the URL loading system. I've used that for several things, from a simple offline caching system for UIWebView to intercepting Pandora traffic.

I also sometimes implement my own schemes with an URLProtocol. For example, the server may send down a custom resource: link, and I'll use an URLProtocol to read that out of the bundle resources (basically the same as WKWebView's WKURLSchemeHandler for this).

Rob Napier
  • 286,113
  • 34
  • 456
  • 610