Skip to content

Instantly share code, notes, and snippets.

@Ibrahimhass
Last active November 23, 2018 21:37
Show Gist options
  • Save Ibrahimhass/77d47c82dd95d9f66eab405ed8d26a5e to your computer and use it in GitHub Desktop.
Save Ibrahimhass/77d47c82dd95d9f66eab405ed8d26a5e to your computer and use it in GitHub Desktop.
Singleton Code
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