So I try to insert dispatch_async(dispatch_get_main_queue()) and doesn't work too. Define “doesn’t work” in this context. Are you saying that it doesn’t get you to the main thread? Or that it doesn’t help you serialise your posts.Is there a way for make post sync post?That is not recommend and, anyway, shouldn’t be necessary.In my case the problem is that I need to do 2 posts, the second one I will do onlyt if the first was successfull.A simple structure for this would be:session.dataTask(… first POST request …) { if let error = error { … dispatch to main thread and post the error … } else { … process server result … if unsuccessful { … dispatch to main thread and post the error … } else { session.dataTask(… second POST request …) { if let error = error { … dispatch to main thread and post the error … } else { … process server result … if unsuccessful { … dispatch to main thread and post the error … } else { … dispatch to main thread and post success … } }
Topic:
App & System Services
SubTopic:
Networking
Tags: