Advanced Networking with URLSession, Episode 3: Upload Data | raywenderlich.com

Learn how to upload data to your local Vapor instance.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/32317111-advanced-networking-with-urlsession/lessons/3

Great episode… great series. I am really appreciating the content and the excitement.

At the end, submitting a review, I notice that the console for the server only shows a rating of 4 (the default given within the app’s RatingView State property).

RatingUploader rating value just before the json.data call on line 35 shows 4
SongDetailView’s submitRatingTapped() ratingView.rating shows 4
RatingView’s state value shows 1

So, the update within the RatingView does not seem to propagate appropriately?

As I walk through the code, as much of this is new to me, I’m not clear where to apply a fix. I would appreciate some guidance for this sort of topic.

Thoughts??? And Thanks,
Frank

Hi Frank, very happy and glad to hear you’re finding the content good and are enjoying it.

Since you mention that RatingView is possibly not updating its state to actually reflect what your true rating is, then I’d start by focusing on the SwiftUI side (an @State property, perhaps) and any code that could cause the disconnect between your data and your UI.

Without seeing a bit of code or screenshot to fully understand what’s happening, it’s difficult to provide a specific solution :slight_smile:

Thanks once again and keep on enjoying the course :smiley:

Ah, yes, my communication skills are lacking . Also, forgot to add: I am a little stoked with Vapor. I’m hoping to set this up at home on a dedicated machine… sorry I digress.

Firstly, absolutely agree the @State property in the RatingView is not propagating to the RatingUploader and SongDetailView’s submitRatingTapped() method.

The code is the code from the tutorial/video. At the end of this video session, this is the behavior I see. I assumed (I know… should not do that): Is it appropriate for me to direct you to that code since it’s already posted? I could provide that, if necessary.

All in all, SwiftUI and dealing with @State properties and passing them around to other members of the code is not what you’re teaching. However, I perceive that behavior is not the intended behavior and I also perceive (leaving room for my possible errors) that is how the tutorial’s code ended in this session.

I can post a link to my code if that makes sense to you (maybe git?). But the code I reference is taking the starter code from this episode and implementing what you walked us through.

Thoughts? And Sincere THANKS!!!

Posting a link to git or snippets of code are no problem at all, even better if it leads us to find (and fix) any possible errors in the sample projects or video itself :slight_smile: