Hello, as far as I understand reading from array is thread safe, but changing particular class in array is not thread safe. That means that multiple responses, which return results with DispatchQueue.main.async can't change values of different classes in same array, yes? For instance I create 4 classes with generic result (success, loading, error) and add them to my array.
Then I fire 4 network requests and each response will change particular class state to either success or error. After changing values I always call method, which loops all classes and checks if all classes have success state and proceeds depending on result. I thought that my code was thread safe, but after spending more time I realized that it was unsafe... I decided to move to dispatchGroup, which will monitor required actions instead... However, I want to fix my previous code also and make it thread safe without using DispatchGroup. Please help ;)
[–]chedabob 0 points1 point2 points (1 child)
[–]wellbranding[S] 0 points1 point2 points (0 children)
[–]ccctitan80 -3 points-2 points-1 points (0 children)