Re: Alerts in Xcode 11

2019-10-16 Thread Alex Zavatone via Cocoa-dev
Yeah, one thing you need to do is get the key window’s presentedViewController. You can do this from the shared applicationDelegate. Create a standalone class that gets UIApplication.shared().keywindow.presentedViewController. Think of that as self. And then use that to present the alert. A

Re: Alerts in Xcode 11

2019-10-16 Thread Doug Hardie via Cocoa-dev
I finally got some time to get back to this again. The extension does a lot of what I need. It works great if it is called from any UIViewController. However, if I call it from a function that is not in a view controller then Swift says notificationAlert is not defined. There is another side

Re: Alerts in Xcode 11

2019-10-09 Thread Alex Zavatone via Cocoa-dev
Just try it with the window code commented out. In any case, where you do have your code with the window, I would expect that you would make the window key and visible not manually adjust its layer and on dismiss, simply resign. Alex Zavatone Sent from my iPhone > On Sep 30, 2019, at 4:48 P

Re: Alerts in Xcode 11

2019-10-09 Thread davelist--- via Cocoa-dev
I'm by no means an expert but if I understand what you're trying to do, I think the approach I would take is to make an extension on UIViewController: extension UIViewController { func notificationAlert(_ msg1: String, _ msg2: String) { // create the UIAlertAlertController //

Re: Alerts in Xcode 11

2019-09-30 Thread Doug Hardie via Cocoa-dev
I tried that and swift complains that self is not defined. This is not in a view controller but a stand alone function used in many view controllers. Generally it is used during a segue, but I added one in a view controller to a button action, not part of a segue and it dismissed the alert als

Re: Alerts in Xcode 11

2019-09-30 Thread David Duncan via Cocoa-dev
Instead of creating a new window and a root view controller in order to present your alert, just use (assuming self is a UIViewController) self.present(, animated: completion: …) > On Sep 30, 2019, at 5:48 PM, Doug Hardie wrote: > > Not sure how to do that. It's not in any view controller as

Re: Alerts in Xcode 11

2019-09-30 Thread Doug Hardie via Cocoa-dev
Not sure how to do that. It's not in any view controller as it is used in virtually all of the various view controllers. That's why I wanted it as a function. -- Doug > On 30 September 2019, at 14:44, David Duncan wrote: > > What happens if you present it over your normal view controller hi

Re: Alerts in Xcode 11

2019-09-30 Thread David Duncan via Cocoa-dev
What happens if you present it over your normal view controller hierarchy instead of using another window? Has your application adopted UIWindowScene? > On Sep 30, 2019, at 5:36 PM, Doug Hardie via Cocoa-dev > wrote: > > I have some code that presents an alert to the user with information the