boolean field UIAlertController swift

649 Views Asked by At

Is there any way I can have a 'Boolean' field in an .Alert style UIAlertController or may be convert any of the available fields that can be added to .Alert into a 'Bool' value when reading the value from the field?

1

There are 1 best solutions below

0
On BEST ANSWER

There's no built-in support to add any type of checkbox or toggle to the AlertController.

There is a somewhat related question showing a hack for adding a (picker) control to an UIAlertController. You could add a button showing a checkmark/checkbox image, which the user could toggle, but it would be a very fragile solution.

If possible for your design, setup YES and NO actions, and set your Boolean depending on the selected action. If that conflicts with other actions you are also presenting, you'll probably need to present your own modal (form sheet) custom view controller with some form of toggle control.