title: Is there a way to use NSURLProtocol in a NSURLSession with custom config?
body: <p>I have a NSURLSession that runs in a background queue. I'm adding my <code>NSURLProtocol</code> subclass to the <code>NSURLsessionConfiguration.protocolClases</code> but the <code>override class func canInitWithRequest(request: NSURLRequest) -&gt; Bool</code> never gets called.</p>
  
  <p>This is how I'm adding my <code>NSURLProtocol</code></p>
  
  <pre><code>let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
  configuration.protocolClasses!.append(MockNetwork)
  urlSession = NSURLSession(configuration: configuration, delegate: self, delegateQueue: operationQueue)
  </code></pre>
  
  <p>Also I tried with the session not running on background doing but also didn't work:</p>
  
  <pre><code>let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
  configuration.protocolClasses!.append(MockNetwork)
  urlSession = NSURLSession(configuration: configuration)
  </code></pre>
  
  <p>As this was not working I just tried:</p>
  
  <pre><code>urlSession = NSURLSession.sharedSession()
  </code></pre>
  
  <p>And calling this in my AppDelegate </p>
  
  <pre><code>NSURLProtocol.registerClass(MockNetwork)
  </code></pre>
  
  <p>This does work, what am I doing wrong?!</p>