Globals
open class Globals
Undocumented
-
Undocumented
Declaration
Swift
public init()
-
Compares two
CGSizes with 0.0001 toleranceDeclaration
Swift
open func isCGSizesEqual(first: CGSize, second: CGSize) -> Bool
-
Shared application
Declaration
Swift
open var sharedApplication: UIApplication { get } -
Default file manager
Declaration
Swift
open var sharedFileManager: FileManager { get } -
Default notification center
Declaration
Swift
open var sharedNotificationCenter: NotificationCenter { get } -
Shared user defaults
Declaration
Swift
open var sharedUserDefaults: UserDefaults { get } -
Application’s key window
Declaration
Swift
open var keyWindow: UIWindow? { get } -
Application’s window. Crashes if nil.
Declaration
Swift
open var appWindow: UIWindow { get } -
Is application in
activestate?Declaration
Swift
open var isAppActive: Bool { get }
-
Undocumented
Declaration
Swift
open func perform(_ closure: SimpleClosure) -> NSException?
-
Removes nested optionals until only one left
Declaration
Swift
open func unwrap(_ _any: Any?) -> Any?
-
Current top most view controller
Declaration
Swift
public var topViewController: UIViewController? { get } -
Returns top view controller from
basecontroller.Note
In case you are using custom container controllers in your application this method won’t be able to process them.Declaration
Swift
open func topViewController(base: UIViewController? = nil, shouldCheckPresented: Bool = true) -> UIViewController?Parameters
baseBase controller from which to start. If not specified or nil then application delegate window’s rootViewController will be used.
shouldCheckPresentedShould it check for presented controllers?
-
Returns top most view controller that handles status bar style. This property might be more accurate than
topViewControllerif custom container view controllers configured properly to return their top most controllers for status bar appearance.Declaration
Swift
public var statusBarStyleTopViewController: UIViewController? { get }
-
Undocumented
Declaration
Swift
open func animate(animations: @escaping SimpleClosure) -
Undocumented
Declaration
Swift
open func animate(_ duration: TimeInterval, animations: @escaping SimpleClosure) -
Undocumented
Declaration
Swift
open func animate(_ duration: TimeInterval, options: UIView.AnimationOptions, animations: @escaping SimpleClosure) -
Undocumented
Declaration
Swift
open func animate(_ duration: TimeInterval = 0.3, delay: TimeInterval = 0, options: UIView.AnimationOptions = .beginFromCurrentState, animations: @escaping SimpleClosure, completion: ((Bool) -> ())? = nil)
-
Executes a closure in a default queue after requested seconds. Uses GCD.
Declaration
Swift
open func asyncBg(_ delay: TimeInterval = 0, closure: @escaping SimpleClosure)Parameters
delaynumber of seconds to delay
closurethe closure to be executed
-
Executes a closure if already in background or dispatch asyn in background. Uses GCD.
Declaration
Swift
open func performInBackground(_ closure: @escaping SimpleClosure)Parameters
closurethe closure to be executed
-
Executes a closure in the main queue after requested seconds asynchronously. Uses GCD.
Declaration
Swift
open func asyncMain(_ delay: TimeInterval = 0, closure: @escaping SimpleClosure)Parameters
delaynumber of seconds to delay
closurethe closure to be executed
-
Executes a closure if already in main or dispatch asyn in main. Uses GCD.
Declaration
Swift
open func performInMain(_ closure: @escaping SimpleClosure)Parameters
closurethe closure to be executed
-
Helper function that mimics objc @synchronized(self) {…} behaviour and syntax
Declaration
Swift
open func synchronized(_ lock: Any, closure: () throws -> Void) rethrows
-
Shows error alert with title, message, action title, cancel title and handler
Declaration
Swift
open func showErrorAlert(title: String? = nil, message: String? = nil, actionTitle: String = "Dismiss", style: UIAlertAction.Style = .cancel, cancelTitle: String? = nil, onCancel: (() -> Void)? = nil, handler: (() -> Void)? = nil)Parameters
titleAlert title. Default is
nil- no title.messageAlert message. Default is
nil- no message.actionTitleAction button title. Default is
Dismiss.styleAction button style. Default is
.cancel.cancelTitleCancel button title. Default is
nil- no cancel button.onCancelCancel button click closure. Default is
nil- no action.handlerAction button click closure. Default is
nil- no action. -
Shows enter text alert with title and message
Declaration
Swift
open func showEnterTextAlert(title: String? = nil, message: String? = nil, text: String? = nil, placeholder: String? = nil, onCancel: (() -> Void)? = nil, completion: @escaping (_ text: String) -> ())Parameters
titleAlert title
messageAlert message
placeholderText field placeholder
onCancelCancel button click closure. Default is
nil- no action.completionClosure that takes user entered text as parameter
-
Shows picker alert with title and message.
Declaration
Swift
open func showPickerAlert(title: String? = nil, message: String? = nil, buttons: [String], buttonsStyles: [UIAlertAction.Style]? = nil, enabledButtons: [Bool]? = nil, onCancel: (() -> Void)? = nil, completion: @escaping ((String, Int) -> ()))Parameters
titleAlert title
buttonsButton titles
buttonsStylesButton styles
enabledButtonsEnabled buttons
onCancelCancel button click closure. Default is
nil- no action.completionClosure that takes button title and button index as its parameters
-
Undocumented
Declaration
Swift
public typealias EmailAttachment = (data: Data, mimeType: String, fileName: String) -
Tries to send email with MFMailComposeViewController first. If can’t uses mailto: url scheme.
Declaration
Swift
open func sendEmail(to: String, title: String? = nil, body: String? = nil)Parameters
toAddressee’s email
titleOptional email title
bodyOptional email body
-
Sends email with MFMailComposeViewController. Won’t do anything if
MFMailComposeViewController.canSendMail()returns false.Declaration
Swift
open func sendEmailUsingMailComposer(to: String, title: String? = nil, body: String? = nil, attachments: [EmailAttachment] = []) -> BoolParameters
toAddressee’s email
titleOptional email title
bodyOptional email body
attachmentsTyples with data, mime type and file name.
Return Value
false if can not send email
-
Sends email using mailto: url scheme. Won’t do anything if URL can not be composed.
Declaration
Swift
open func sendEmailUsingMailto(to: String, title: String? = nil, body: String? = nil)Parameters
toAddressee’s email
titleOptional email title
bodyOptional email body
-
Undocumented
Declaration
Swift
open func showNetworkActivity() -
Undocumented
Declaration
Swift
open func hideNetworkActivity()
-
Swizzles meta class methods
Declaration
Swift
open func swizzleClassMethods(class: AnyClass, originalSelector: Selector, swizzledSelector: Selector) -
Swizzles class methods
Declaration
Swift
open func swizzleMethods(class: AnyClass, originalSelector: Selector, swizzledSelector: Selector)
-
Returns all classes that conforms to specified protocol. Protocol must be declared with @objc annotation. Takes 0.003s - 0.02s on 5s device. Example usage:
let setupOnes: [SetupOnce.Type] = getClassesConformToProtocol(SetupOnce.self) // or let setupOnes = getClassesConformToProtocol(SetupOnce.self) as [SetupOnce.Type]Declaration
Swift
open func getClassesConformToProtocol<T>(_ protocol: Protocol) -> [T] -
Returns all child classes for specified class. Not recursively. Takes 0.015s on 5s device. Example usage:
let childClasses = getChildrenClasses(UIViewController.self)Declaration
Swift
open func getChildrenClasses<T>(of class: T.Type) -> [T.Type] where T : AnyObject -
Undocumented
Declaration
Swift
open func getMethodsList(object: AnyObject) -> [String]? -
Returns string prepresentation of object’s pointer
Declaration
Swift
open func getPointer(_ any: AnyObject) -> String -
Undocumented
Declaration
Swift
open func Translate(_ string: String) -> String -
Opens iOS Settings page for current application
Declaration
Swift
open func openAppSettings()
Globals Class Reference