SkillAgentSearch skills...

AlertController

An NSViewController to display an alert message to the user. This class replaces the NSAlert class.

Install / Use

/learn @phimage/AlertController
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

AlertController

License Platform Language Issues Cocoapod

A NSViewController to display an alert message to the user. This class replaces the NSAlert class and is inspired from UIAlertController.

After configuring the alert controller with the actions and style you want, present it using presentViewControllerAsSheet.

let controller = AlertController(title: "Alert title", message: "An alert message", preferredStyle: .warning)
parentVC.presentViewControllerAsSheet(controller)

<img align="center" src="Demo/DemoInfo.png"> ## Usage

Add a simple dismiss action

controller.add(action: AlertAction.dismiss(for: controller, title: "Ok"))

Add custom action

controller.add(action: AlertAction(title: "Report...") { action in
    NSWorkspace.shared().open(URL(string: "https://github.com/phimage/AlertController/issues")!)
})

Choose a style

controller.addAction(title: "", style: .helpButton) { action in
    // show error help
}

Customize buttons bar

controller.buttonsBar.color = NSColor.red
controller.buttonsBar.buttonSpace = 8
<img align="center" src="Demo/DemoAlert.png">

Todo

  • More customization
    • align buttons left or right
    • automatic helpButton on left
  • Maybe input text fields

Installation

Using CocoaPods

CocoaPods is a centralized dependency manager for Objective-C and Swift. Go here to learn more.

  1. Add the project to your Podfile.

    use_frameworks!
    
    pod 'NSAlertController'
    
  2. Run pod install and open the .xcworkspace file to launch Xcode.

Using Carthage

github 'phimage/AlertController'
View on GitHub
GitHub Stars8
CategoryDevelopment
Updated10mo ago
Forks4

Languages

Swift

Security Score

77/100

Audited on Jun 1, 2025

No findings