I have a function that will sync iCloud and I will be calling it from several view controllers. I want to have it display an alert if iCloud isn't available (either it was always off or the user signed out since the last visit, whatever). Would there be a way to add the alert code inside the function and have it display inside the VC the function is called inside?
func synciCloud(){
if iCloudIsAvailable() {
// stuff to sync iCloud
} else {
// where I'd like to call the alert
}
}
Then later:
class List: UIViewController {
override func viewDidLoad() {
synciCloud()
// this won't actually run on viewDidLoad but I'm just showing an example.
}
}
So would there be a way to achieve this or am I thinking about it all wrong? Thank you.