Latest 1.0.0
Homepage https://github.com/cszatma/HotCocoa
License MIT
Platforms ios 8.0, osx 10.10, tvos 9.0
Frameworks Foundation
Authors

Language Swift
Version
License
Platform

HotCocoa is a list of extensions that provides extra functionality and syntactic sugar for Cocoa and Cocoa Touch.

Examples

UIColor & NSColor

Construct a UIColor or NSColor with rgb values from 0 to 255:

let color = UIColor(r: 5, g: 185, b: 255)

Or

let color = NSColor(r: 5, g: 185, b: 255)

Construct a UIColorfrom a hex number:

let color = UIColor(hex: 0x02B8FF)

Or a hex string:

let color = UIColor(hexString: "02B8FF")

UIWindow

Easily create and show a new UIWindow with a given UIViewController:

let window = UIWindow(rootViewController: ViewController()) // UIScreen.main.bounds is the default frame

or

let window = UIWindow(frame: myRect, rootViewController: ViewController())

UIViewController

Easily dismiss the keyboard when the user taps the screen:

viewController.hideKeyboardWhenTappedAround()

Easily display a UIAlertController insude your UIViewController:

var actions = [UIAlertActions]()
...
viewController.displayAlertController(title: "Important", message: "This is an alert!", actions: actions) // A completion closure can be added if necessary

UserDefaults

Easily save any value that conforms to the Codable protocol to UserDefaults

struct MyStruct: Codable { ... }

let myStruct = MyStruct()
UserDefaults.standard.set(object: myStruct, forKey: "myStruct")

and retrieve it just as easily

myStruct = UserDefaults.get(type: MyStruct, forKey: "myStruct")

And much more!

Use it in a project to see what’s available.

Installation

Requirements

  • iOS 8.0+
  • macOS 10.10+
  • tvOS 9.0+
  • Swift 4

CocoaPods

HotCocoa is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'HotCocoa', '~> 1.0.0'

Contributing

Open an issue or submit a pull request.

Latest podspec

{
    "name": "HotCocoa",
    "version": "1.0.0",
    "summary": "Sugar for Cocoa and Cocoa Touch.",
    "description": "HotCocoa adds extensions to Cocoa and Cocoa Touch to improve functionality and make tasks simpler",
    "homepage": "https://github.com/cszatma/HotCocoa",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Christopher Szatmary": "[email protected]"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/cszatma/HotCocoa.git",
        "tag": "1.0.0"
    },
    "source_files": "HotCocoa/**/*.{swift}",
    "frameworks": "Foundation",
    "ios": {
        "frameworks": "UIKit"
    },
    "osx": {
        "frameworks": "AppKit"
    }
}

Pin It on Pinterest

Share This