Skip to content
Gabriel Theodoropoulos edited this page Apr 17, 2019 · 5 revisions

GTAlertCollection Wiki

This page contains general guidelines on how to use GTAlertCollection in your projects. Use the links on the right to visit all GTAlertCollection wiki pages.

Available alert types

GTAlertCollection provides the following types of alerts (alert controllers - UIAlertController instances):

  • Single-button alert controller
  • Alert controller with variable number of buttons with all supported styles: Default, Cancel, Destructive
  • Buttonless alert controller
  • Alert controller with an activity indicator
  • Alert controller with a progress bar, including text representation of the progress (either percentage, or number of steps made)
  • Alert controller with a single text field
  • Alert controller with multiple text fields
  • Alert controller with an image view

Using GTAlertCollection

There is one requirement before we start using any of the GTAlertCollection methods; to specify the host view controller, meaning the view controller where the alert controller will be presented to. This can be done in two ways, depending on how we are planning to GTAlertCollection:

The first is to initialise a custom object of it. Declare the following property in your class:

var alertCollection: GTAlertCollection!

And then in the viewDidLoad() initialise it using the following init method:

alertCollection = GTAlertCollection(withHostViewController: self)

After that, use the alertCollection object to access all public methods and properties.

GTAlertCollection can be also used as a singleton class, something that might be a more flexible way to use it. Just use the shared property of the GTAlertCollection class. In this case you have to set the host view controller manually. The best place to do that would be once again either in the viewDidLoad() method.

GTAlertCollection.shared.hostViewController = self