     }
 }
 
-class SuperMockRecordingURLProtocol: NSURLProtocol {
+class SuperMockRecordingURLProtocol: URLProtocol {
     
     var connection : NSURLConnection?
     var mutableData : NSMutableData?
+    var dataTask: URLSessionDataTask?
+    var response: URLResponse?
     
-    override class func canInitWithRequest(request: NSURLRequest) -> Bool {
+    override class func canInit(with request: URLRequest) -> Bool {
         
-        if let _ = NSURLProtocol.propertyForKey("SuperMockRecordingURLProtocol", inRequest: request) {
+        if let _ = URLProtocol.property(forKey: "SuperMockRecordingURLProtocol", in: request) {
             return false
         }
         if SuperMockResponseHelper.sharedHelper.recording  {


import UIKit

class SuperMockURLProtocol: NSURLProtocol {
    
    override class func canInitWithRequest(request: NSURLRequest) -> Bool {
        
        if request.hasMock() {
            print("Requesting MOCK for : \(request.URL)")
            return true
        }
        print("Passing Through WITHOUT MOCK : \(request.URL)")
        return false
    }
    
    
    override class func canonicalRequestForRequest(request: NSURLRequest) -> NSURLRequest {
        return request
    }


        let mockedRequest = SuperMockResponseHelper.sharedHelper.mockRequest(request)
        if let mockData = SuperMockResponseHelper.sharedHelper.responseForMockRequest(mockedRequest) {
   
            let mimeType = SuperMockResponseHelper.sharedHelper.mimeType(mockedRequest.url!)
            var response = URLResponse(url: mockedRequest.url!, mimeType: mimeType, expectedContentLength: mockData.count, textEncodingName: "utf8")
            if let mockResponse = SuperMockResponseHelper.sharedHelper.mockResponse(request) {
                response = mockResponse
            }
            
            client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed)
            client?.urlProtocol(self, didLoad: mockData)
            client?.urlProtocolDidFinishLoading(self)
        }
    }
    
