Also a good point.
Thanks!
So maybe like so:
showThrobber()
// The reason for the asyncAfter(), is that we need to give the throbber time to show up.
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + DispatchTimeInterval.milliseconds(20)) {
I tend to like to put comments to the right of the lines, but not if they are long ones.I don’t usually like to put stuff just under opening braces, because I feel that it can sometimes obscure the fact that a new context was opened.
Indentation is important. Back when I programmed C++, I used Whitesmiths indentation, but I changed to K&R, when I started writing Swift. With Whitesmiths, you can put a long comment, just above the context opening, and the comment can apply to just the context, and not the opening statement. This established a habit of having comments apply to the line below.
Here's an example of the same kind of thing, in another part of the same codebase:
if userFallbackRaw == (inError! as NSError).code { // Fallback means that we will use the password, so we nuke the stored password.
#if DEBUG
print("Biometric fallback.")
#endif
// Wow. This is one hell of a kludge, but it works.
// There's a "feature" in iOS, where the Touch/FaceID callback is triggered out of sync with the main queue (slightly before the next run cycle, I guess).
// If we immediately set the password field as first responder in this callback, then it gets selected, but the keyboard doesn't come up.
// This 'orrible, 'orrible hack tells iOS to select the field after the handler for this Touch/FaceID has had time to wrap up.
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + DispatchTimeInterval.milliseconds(20)) {
self._bioHazard = true
self._selectedPassword = ""
self.emailAddressTextField?.text = self._selectedLogin
self.passwordTextField?.text = ""
self.isThrobberShown = false
self.passwordTextField?.becomeFirstResponder()
}