CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

NSURLSession-PromiseKit 0.3.2

NSURLSession-PromiseKit 0.3.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Oct 2015

Maintained by Jonas Schmid.



Usage

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);
});

Example project

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.

Requirements

Installation

NSURLSession-PromiseKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'NSURLSession-PromiseKit'

Author

Jonas Schmid, [email protected]

License

NSURLSession-PromiseKit is available under the MIT license. See the LICENSE file for more info.