venmo / DVR

Network testing for Swift
http://blog.soff.es/network-testing-in-swift-with-dvr
MIT License
650 stars 86 forks source link

[DVR.Session delegate]: unrecognized selector #45

Open jefflovejapan opened 8 years ago

jefflovejapan commented 8 years ago

I'm trying to use a DVR Session with Alamofire but using it to initialize a Manager generates an unrecognized selector exception.

This conversation deals with my use case, but the advice ("Just create a session delegate, then create your custom session, and pass both in.") doesn't seem to work. Since DVR's Session is a subclass of NSURLSession I would expect that you could ask for its delegate but it's breaking for some reason.

let delegate = Manager.SessionDelegate()
let backingSession = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration(), delegate: delegate, delegateQueue: nil)
let maybeBundle = NSBundle.allBundles().filter{ $0.bundlePath.lowercaseString.containsString("xctest") }.first
if let bundle = maybeBundle {
    let session = Session(outputDirectory: "~/Desktop/DVR/", cassetteName: cassetteName, testBundle: bundle, backingSession: backingSession)
}
gsholtz commented 8 years ago

I'm having the same issue as @jefflovejapan is having. I created the objects as advised (Session delegate and custom session), but if the moment I instantiate the Alamofire.Manager with both, I get this error: "[DVR.Session delegate]: unrecognized selector sent to instance (instance address)".