Both Papushev and Quinn "The Eskimo"!" suggested that instead of doing an explicit syncrhonization, I might want to leverage the
dispatch_main
method.
This is where the API documentation really fell on its face IMNSHO.
The Apple documentation really gives very little clue as to how to use this thing. Specifically, the only thing that the do suggests is that the function waits for sumitted tasks to complete. Unfortunately, the pdataTask:with:completionHandler documentation gives no indictation that it sumbmits to the main queue. I suppose that's guessable, but probably not desirable in documentation. The only reference to queues is in reference to a delegate -- which I did not use. I wound up going pretty far afield trying to process Quinn and Papushev's tip that I look into dispatch_main
.
This SO post was better, althought its lede was buried in a comment.
Thank you so much! I have spend hours trying to find out why my command line tool does not fire the request and your code using the Dispatchgroup solved it for me.