|
Hii to all programmers, I'm new to the whole concept of network calls, and I have some issues with my code that I would like to resolve, but don't know how. The whole app works (https://github.com/Tim-engineer/WBPO-SwiftUI): But I have problem with creating the following button to have it's own value for each user, I haven't figured how can I do this almost whole day, so I'm asking if somebody can help me and teach me what can I do different.
|
|
Your logic should revolve on the idea of User having property isFollowed, as this is the state of truth for each user. You cannot add this property directly to JSON received as it will not be decoded and end up with invalid data. You may think to create a separate object that copies a user received and then adds property isFollowed which later can be used to follow or unfollow. But with current structure of JSON, it's not really so easy. If JSON have have a user with such property then it is much easier. |
|
In the example below I will use more fresh
|
|
Thank youuu soo much I really appretiate your work. It's littlebit too complicated for beginners to add isFollowed and combine it with network call. As you said it would be much easier if it was in the API. I've learned a lot from you thank you. :) |
SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.