CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.
TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Oct 2015 |
Maintained by Jonas Schmid.
Import the category
#import "NSURLSession+PromiseKit.h"
Create a NSURLSession
like you are used to:
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
Then use the category messages to get a PMKPromise
instead of a NSURLSessionTask
.
NSURL *url = [NSURL URLWithString:@"http://pastebin.com/raw.php?i=1gdNuVSh"];
[self.session promiseDataTaskWithURL:url].then( ^(NSData *data, NSURLResponse *response) {
NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"Result: %@", result);
}).catch( ^(NSError *e) {
NSLog(@"Error: %@", e);
});
To try the example project, run:
pod try 'NSURLSession-PromiseKit'
You can also clone the repo, run pod install
from the Example directory, and open NSURLSession-PromiseKit.xcworkspace.
NSURLSession-PromiseKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'NSURLSession-PromiseKit'
Jonas Schmid, [email protected]
NSURLSession-PromiseKit is available under the MIT license. See the LICENSE file for more info.