venmo / DVR

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

Session delegate (Alamofire) support - closes #11, closes #12 #41

Closed srdanrasic closed 1 year ago

srdanrasic commented 8 years ago

This enables DVR to work with Alamofire.

let delegate = Manager.SessionDelegate()
let session = Session(cassetteName: "example", delegate: delegate)
let manager = Manager(session: session, delegate: delegate)
dgdosen commented 8 years ago

Can you clarify why you need to create and manage task ids?

srdanrasic commented 8 years ago

Because NSURLSessionDataTask/NSURLSessionTask does not implement taskIdentifier property.

If you try executing

let task = NSURLSessionDataTask()
print(task.taskIdentifier)

your program will crash. I guess under the hood it's implemented as Objective-C @dynamic property.

That's why I need to handle task identifiers and other properties that I've overridden manually.

phatmann commented 8 years ago

Can Alamofire be used with DVR even without this PR? Supposedly this Alamofire PR allows DVR to be used with it.

hugobast commented 8 years ago

@phatmann the Alamofire PR you mention is absolutely advancing the goal of DVR + Alamofire. What it does is add a failable init to configure a Manager with a different Session. That's great and it works great. On DVR's side there are things required in order to work:

Let me know if I can do anything to advance this PR and give it a chance to be merged. It would be great to have that Alamofire supported.

nebiros commented 6 years ago

Got the same error as @srdanrasic:

"-[DVR.SessionDataTask taskIdentifier]: unrecognized selector sent to instance 0x60b000064a60"