Latest 0.1.0
Homepage https://github.com/bakkenbaeck/Sweetness
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0, requires ARC
Dependencies SweetCoreData, SweetUIKit
Authors

Version
Carthage compatible
platforms
License

SweetUIKit

UIAlertController

Dismissable alert

let alertController = UIAlertController.dismissableAlert(title: "Not allowed access", message: "Please contact your admin to get access.")
self.presentViewController(alertController, animated: true, completion: nil)

Destructive confirmation alert

let alertController = UIAlertController.destructiveConfirmationAlert(message: "Are you sure you want to log out?", destructiveActionTitle: "Log out") {
    self.controllerDelegate?.settingsControllerDidPressLogoutButton(self)
}
self.presentViewController(alertController, animated: true, completion: nil)

Error alert

let alertController = UIAlertController.errorAlert(error)
self.presentViewController(alertController, animated: true, completion: nil)

Progress alert

let progressAlert = UIAlertController.progressAlert("Creating album...")
self.presentViewController(progressAlert, animated: true, completion: nil)
self.fetcher.createAlbum(title: self.titleTextField.text, photos: self.selectedPhotos) { error in
    progressAlert.dismissViewControllerAnimated(true) {
        if let error = error {
            let alertController = UIAlertController.errorAlert(error)
            self.presentViewController(alertController, animated: true, completion: nil)
        } else {
            // Success
        }
    }
}

UILabel

Calculate width

let width = self.usernameLabel.width()
// Do something with new width

UIView

Shake

self.fetcher.authenticate(username, password: password) { clientID, clientSecret, accessToken, refreshToken, expiresIn, error in
    if let error = error {
        // Update UI to display error
        self.tableView.shake()
    } else {
      // success
    }
}

UIImage

Centered frame

let image = UIImage(named: "art.png")!
let frame = image.centeredFrame()
// Do something with new frame

UIViewController

Application window

let window = self.applicationWindow()

SweetCoreData

NSManagedObjectContext

Drop entity

let context = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
context.dropEntity("User")

Count entity

let context = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
let count = context.countEntity("User")

Fetch entity (with generics)

let context = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
let users: [User] = context.fetchEntity("User")

Installation

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

pod 'Sweetness'

Sweetness is also available through Carthage. To install
it, simply add the following line to your Cartfile:

github "bakkenbaeck/Sweetness"

License

Sweetness is available under the MIT license. See the LICENSE file for more info.

Author

Bakken & Bæck AS, @bakkenbaeck

Latest podspec

{
    "name": "Sweetness",
    "summary": "A collection of sugar and helpers for UIKit, CoreData, Foundation, Swift and more.",
    "version": "0.1.0",
    "homepage": "https://github.com/bakkenbaeck/Sweetness",
    "license": "MIT",
    "authors": {
        "Bakken & Bu00e6ck AS": "[email protected]"
    },
    "source": {
        "git": "https://github.com/bakkenbaeck/Sweetness.git",
        "tag": "0.1.0"
    },
    "social_media_url": "https://twitter.com/bakkenbaeck",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "requires_arc": true,
    "dependencies": {
        "SweetCoreData": [],
        "SweetUIKit": []
    }
}

Pin It on Pinterest

Share This