Modern development is highly asynchronous: isn’t it about time we had tools that made programming asynchronously powerful, easy and delightful?
UIApplication.sharedApplication().networkActivityIndicatorVisible = true
when(fetchImage(), getLocation()).then { image, location in
self.imageView.image = image;
self.label.text = "Buy your cat a house in \(location)"
}.always {
UIApplication.sharedApplication().networkActivityIndicatorVisible = false
}.error { error in
UIAlertView(…).show()
}
PromiseKit is a thoughtful and complete implementation of promises for iOS and OS X with first-class support for both Objective-C and Swift.
#CocoaPods
pod "PromiseKit", "~> 3.4"
#Carthage
github "mxcl/PromiseKit" ~> 3.4
Alternatively, clone PromiseKit and drag and drop its xcodeproj
into your Xcode project.
- We have a gentle but thorough introduction to PromiseKit at promisekit.org.
PromiseKit contains Swift, so we engage in an unending battle with Xcode:
Xcode | Swift | PromiseKit |
---|---|---|
8 | 3.0 | 4 |
8 | 2.3 | 3 |
7 | 2.2 | 3 |
6 | 1.2 | 2 |
* | N/A | 1 |
PromiseKit 1 is pure Objective-C and thus works with all Xcodes, it is also your only choice if you need to support iOS 7 or below.
We maintain some branches to aid migrating between Swift versions:
Xcode | Swift | PromiseKit | Branch |
---|---|---|---|
7.3 | 2.2 | 2 | swift-2.2-minimal-changes |
7.2 | 2.2 | 2 | swift-2.2-minimal-changes |
7.1 | 2.1 | 2 | swift-2.0-minimal-changes |
7.0 | 2.0 | 2 | swift-2.0-minimal-changes |
We do not backport fixes (mostly) to these migration-branches.
PromiseKit is lucky enough to have a large community behind it which is reflected in our Gitter chat. If you're new to PromiseKit and are stumped or otherwise have a question that doesn't feel like an issue (and isn't answered in our documentation) then our Gitter is a great place to go for help. Of course if you're onto something that you believe is broken or could be improved then opening a new issue is still the way to go 👍.
PromiseKit is hundreds of hours of work almost completely by just me: Max Howell. I thoroughly enjoyed making PromiseKit, but nevertheless if you have found it useful then your bitcoin will give me a warm fuzzy feeling from my head right down to my toes: 1JDbV5zuym3jFw4kBCc5Z758maUD8e4dKR.
Copyright 2015, Max Howell; [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.