Sweetness 0.1.0

Sweetness 0.1.0

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最新版本2016年5月
SPM支持 SPM

Elvis Nuñez 维护。



 
依赖关系
SweetCoreData>= 0
SweetUIKit>= 0
 

Sweetness 0.1.0

SweetUIKit

UIAlertController

可取消 alert

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

破坏性确认 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)

错误 alert

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

进度 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

计算宽度

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

UIView

摇晃

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

居中 frame

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

UIViewController

应用程序窗口

let window = self.applicationWindow()

SweetCoreData

NSManagedObjectContext

删除实体

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

计数实体

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

获取实体(使用泛型)

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

安装

Sweetness 可通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中即可

pod 'Sweetness'

甜度 同样可以通过 Carthage 获取。要安装它,只需将以下行添加到您的 Cartfile 中

github "bakkenbaeck/Sweetness"

许可证

甜度 采用 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。

作者

Bakken & Bæck AS, @bakkenbaeck