You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code could use some improvement: Currently it starts its own thread to download the data, then starts a synchronous request (which in turn starts its own thread and blocks until that returns). What this should really do is just use one of the asynchronous networking calls (or even better, use NSURLSession's asynchronous calls to fetch the current app version from the app store)
It also does several performSelectorOnMainThread: calls after one another. Each such call has an overhead. It would be much cleaner if it just did one performSelectorOnMainThread: and had that call one method that does the 4 or so calls that need to be on the main thread.
Finally, the way it creates the singleton in +load with performSelectorOnMainThread: waitUntilDone: NO has a race condition. This should really just be using dispatch_once like one does these days to set up a singleton thread-safely.
The text was updated successfully, but these errors were encountered:
@uliwitness I don't disagree. This code predates GCD (iOS 3.x), and has no unit tests, so there's a significant cost/benefit issue with refactoring it. If I ever need to use it myself in a new application, I'll consider a rewrite.
This code could use some improvement: Currently it starts its own thread to download the data, then starts a synchronous request (which in turn starts its own thread and blocks until that returns). What this should really do is just use one of the asynchronous networking calls (or even better, use NSURLSession's asynchronous calls to fetch the current app version from the app store)
It also does several performSelectorOnMainThread: calls after one another. Each such call has an overhead. It would be much cleaner if it just did one performSelectorOnMainThread: and had that call one method that does the 4 or so calls that need to be on the main thread.
Finally, the way it creates the singleton in +load with
performSelectorOnMainThread: waitUntilDone: NO
has a race condition. This should really just be usingdispatch_once
like one does these days to set up a singleton thread-safely.The text was updated successfully, but these errors were encountered: