Either monad to simplify data in completion blocks
Heavily influenced by Fallible by brentdax and Result of Alamofire. Failable data is generic and can return item(s) or if failed an optional ErrorType.
- iOS 8.0+ / Mac OS X 10.9+ / tvOS 9.0+ / watchOS 2.0+
- Xcode 7.3+
Embedded frameworks require a minimum deployment target of iOS 8 or OS X Mavericks (10.9).
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 0.39.0+ is required.
To integrate Failable into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
pod 'Failable', '~> 0.2.0'
Then, run the following command:
$ pod install
func example(completion: ((data: Failable<String>) -> Void)?) {
completion?(data: .Success("hello"))
}
example { (data) in
if let value = data.value {
print(value)
}
}