Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AlamoFire example wrong? #56

Closed
crayment opened this issue Apr 10, 2016 · 7 comments
Closed

AlamoFire example wrong? #56

crayment opened this issue Apr 10, 2016 · 7 comments
Labels

Comments

@crayment
Copy link

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?

@RuiAAPeres
Copy link
Member

@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)

@crayment
Copy link
Author

@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?

@RuiAAPeres
Copy link
Member

@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.

@crayment
Copy link
Author

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!

@RuiAAPeres
Copy link
Member

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)

@crayment
Copy link
Author

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 :)

@RuiAAPeres
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants