Skip to content

Instantly share code, notes, and snippets.

View ifabijanovic's full-sized avatar

Ivan Fabijanović ifabijanovic

View GitHub Profile
@s4y
s4y / showAlert.swift
Last active March 15, 2016 07:40
A function for showing alerts and action sheets, written for iOS 7 and 8
import UIKit
// Notes:
// - You must explicitly weak link to UIKit to support iOS 7
// - Action sheets on iOS 7 only show a title
func showAlert(viewController: UIViewController, style: UIAlertControllerStyle = .Alert, title: String? = nil, message: String? = nil, sourceView: UIView? = nil, completion: (() -> ())? = nil, buttons: (UIAlertActionStyle, String, (() -> ())?)...) {
if (NSClassFromString("UIAlertController") != nil) {
// iOS 8+