In the given solution
func alert(title: String, text: String?) -> Observable<Void> {
return Observable.create { [weak self] observer in
let alertVC = UIAlertController(title: title, message: text, preferredStyle: .alert)
alertVC.addAction(UIAlertAction(title: "Close", style: .default, handler: {_ in
observer.onCompleted()
}))
self?.present(alertVC, animated: true, completion: nil)
return Disposables.create {
self?.dismiss(animated: true, completion: nil)
}
}
}
why are we calling dismiss method on self in Disposables.create? Isn’t self the UIViewController itself?