Last active
November 23, 2018 21:37
-
-
Save Ibrahimhass/77d47c82dd95d9f66eab405ed8d26a5e to your computer and use it in GitHub Desktop.
Singleton Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static let sharedView : IHProgressHUD = { | |
var localInstance : IHProgressHUD? | |
if Thread.current.isMainThread { | |
if IHProgressHUD.isNotAppExtension { | |
if let window = UIApplication.shared.delegate?.window { | |
localInstance = IHProgressHUD.init(frame: window?.bounds ?? CGRect.zero) | |
} else { | |
localInstance = IHProgressHUD() | |
} | |
} | |
else { | |
localInstance = IHProgressHUD.init(frame: UIScreen.main.bounds) | |
} | |
} else { | |
DispatchQueue.main.sync { | |
if IHProgressHUD.isNotAppExtension { | |
if let window = UIApplication.shared.delegate?.window { | |
localInstance = IHProgressHUD.init(frame: window?.bounds ?? CGRect.zero) | |
} else { | |
localInstance = IHProgressHUD() | |
} | |
} else { | |
localInstance = IHProgressHUD.init(frame: UIScreen.main.bounds) | |
} | |
} | |
} | |
return localInstance! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment