Velhotes/Vinyl

AlamoFire example wrong?

crayment opened this issue · 7 comments

You mention a setup example for working with AlamoFire here but this seems to look over the fact that the recommended init on Manager validates that delegate === session.delegate.

Am I missing something here or this doesn't really work with AlamoFire?

@crayment A Turntable is a NSURLSession subclass, so you can set the delegate. So this should work:

let turntable = Turntable( vinylName: "vinyl_simple", configuration: configuration)
turntable.delegate = aDelegate

let manager = Alamofire.Manager(turntable, delegate: aDelegate)

@RuiAAPeres Thanks for the response! I can't do that because delegate is readonly.

I'd love to use this lib but not sure it's ready. Is my understanding correct that it doesn't create the Vinyls yet? You have to type them out manually?

@crayment that's a good point, we can override the delegate and make it read/write, if I am not mistaken.

As for the lib itself, I have been using it in my own projects and company ones. Right now the library is not recording (WIP #12), but you can easily create it our own. You have two manual choices:

  1. Do it programatically.
  2. Create a vinyl file.

Cool, maybe I will take another stab and try to contribute that change. I assume you guys are using it directly with NSURLSession (skipping Alamofire)?

When you say create the vinyl file programatically - is there already logic in the library to encode a NSHTTPURLResponse?

Thanks again!

We exposed a couple of helper methods, that you can find here. These will create Track objects, that then can be passed to a Vinyl and finally loaded into a Turntable:

let track = TrackFactory.createValidTrack(NSURL(string: "http://feelGoodINC.com")!, body: data, headers: headers)

let vinyl = Vinyl(tracks: [track])
let turntable = Turntable(vinyl: vinyl, configuration: configuration)

Ah I see what you mean by create programatically now. I really think a big part of the advantage of the VCR strategy is that you start with real network requests - so you know they are correct representations of what will come back from the server. Will eagerly await completion of #12 :)

@crayment that's very true! For my personal, and professional, usage, I haven't found a need for it, so I haven't pursue this too much. Will discuss this piece of work with @dmcrodrigues. Hopefully the lack of this feature, won't stop you from using the lib.