Sweetness 0.1.0

Sweetness 0.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release May 2016
SPMSupports SPM

Maintained by Elvis Nuñez.



 
Depends on:
SweetCoreData>= 0
SweetUIKit>= 0
 

Sweetness 0.1.0

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