TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2015 |
SPMSupports SPM | ✗ |
Maintained by Ken Van Hoeylandt.
This project primarily provides Swift support for the Bolts library for OS X and iOS.
It also provides extensions for existing iOS classes.
This project is dependent on the Bolts iOS project through Cocoapods.
Easily start Tasks in the background or on the main thread:
// Background thread task
BFTask.task(.Background, closure:
{
(task: BFTask!) -> AnyObject! in
return nil
})
// Main thread task
BFTask.task(.Main, closure:
{
(task: BFTask!) -> AnyObject! in
return nil
})
Easily continue tasks in the desired way:
findAsync()
.onSuccessInBackground
{
(task: BFTask!) -> AnyObject! in
// background data-processing
let data = process(task.result)
return data
}
.continueInMainThread
{
(task: BFTask!) -> AnyObject! in
if (!task.faulted)
{
UIAlertView(title: "Result",
message: "Task completed",
delegate: nil,
cancelButtonTitle: "OK").show()
}
else
{
UIAlertView(title: "Error",
message: "Task failed",
delegate: nil,
cancelButtonTitle: "OK").show()
}
return nil
}
Resolve image URLs in the background:
UIImage.imageAsync(url)
.onSuccessInMainThread
{
(task: BFTask!) -> AnyObject! in
var image = task.result as? UIImage
return nil
}
Or asynchronously load an image URL into a UIImageView:
imageView.setImageAsync(url)
BoltsSwift is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'BoltsSwift'
Ken Van Hoeylandt, [email protected]
Bolts is available under the MIT license. See the LICENSE file for more info.