I'm working on example code to retrieve a web page using NSURLSession custom delegates instead of the deprecated NSURLConnection.
In my custom delegate TMyDelegate.URLSession_task_didCompleteWithError(session: NSURLSession; task: NSURLSessionTask; error: NSError) procedure I inserted RTLEventSetEvent(ThreadDidFinish) and in the main thread I have RTLEventWaitFor(ThreadDidFinish) before attempting to display the retrieved data.
Alas, this causes the application to crash with this macOS error:
*** -[NSAutoreleasePool release]: This pool has already been released, do not drain it (double release).
I've resorted to setting a boolean at the end of the retrieval completed thread and then waiting for it to be true in the main thread, but I feel unclean
Any ideas?