Awesome Open Source
Awesome Open Source


This is easy to use demo about UIAlertController with code held in one file and access in all other views. This demo is avaialble in both programming lanauage Objective-C & Swift.

What is AlertController?

An object that displays an alert message to the user.



Basic Config:

  1. Xcode 10.0 or above
  2. Objective-C
  3. Swift 4.0 or above
  4. Development Target 10.0 or above
  5. Device Universal Supported

How it Works?

You just need to download this demo and run it inot SIMULATOR or REAL device whatever you want. OR Just copy and paste code from Utility.swift | Utility.h & Utility.m file into your projects and access it!

There are two different project in this repositor:

  1. Objective-C (Utility.h & Utility.m file)

typedef void (^ _Nullable completion)(int index);

+ (void)
shwoAlertControllerInViewController: (UIViewController *)vc withTitle: (nullable NSString *)title andMessage: (nullable NSString *)message withButtons: (NSArray *)button withCompletion: (completion)completionBlock
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    for (int index = 0; index < button.count; index++) {
        UIAlertAction *action = [UIAlertAction actionWithTitle:button[index] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            if (completionBlock != nil) {

        [alertController addAction:action];
    [vc presentViewController:alertController animated:YES completion:nil];
  1. Swift (Utility.swift file)
static func shwoAlertControllerInViewController(vc: UIViewController, withTitle title: String?, andMessage message: String?, withButtons button: [String], completion:((_ index: Int) -> Void)!) -> Void
    let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)

    for index in 0 ..< button.count  {

        let action = UIAlertAction(title: button[index], style: .default, handler: { (alert: UIAlertAction!) in

            if completion != nil {



    vc.present(alertController, animated: true, completion: nil)


This line of codes are avaialble for public use by 9Brainz. If you have any doubts or query regarding this code or any particular topic reagrding iOS Application development, Feel free to Contact Us.


Is this demo helpful for your project? OR Reducing tiny bit of work in your project? Let us know about it 🔥🔥🔥

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Swift (65,199
Objective C (57,184
Programming (18,141
Alert (7,562
Alertview (215
Uialertcontroller (66
Alertcontroller (28
Alert Messages (18
Alertviewcontroller (14