Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save robertmryan/7c13073e7b784664b7c0fc0b2807e80f to your computer and use it in GitHub Desktop.
Save robertmryan/7c13073e7b784664b7c0fc0b2807e80f to your computer and use it in GitHub Desktop.
class SingletonManager {
static let sharedObjectA = ObjectA()
}
class ObjectA {
func performAsyncTask(completionHandler: (String) -> ()) {
// perform something asynchronous which will call `completionHandler` later
completionHandler("foo")
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
SingletonManager.sharedObjectA.performAsyncTask { responseString in
print(responseString)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment