Wrapper for the AFHTTPRequestOperation class to return a PromiseKit promise.
Promises clean up the structure of code and provide better data flow and error handling especially when using asynchronous methods.
- iOS 6.0+
- OS X 10.7+
Install via CocoaPods
-
Add the library to
Podfile
platform :ios, '6.0' pod 'AFNetworking-PromiseKit'
-
Install pod
pod install
- Drop
AFHTTPRequestOperation+PromiseKit.h
,AFHTTPRequestOperation+PromiseKit.m
, andAFNetworking-PromiseKit.h
into an Xcode project with AFNetworking and set the appropriate targets.
-
Manual install
#import "AFNetworking-PromiseKit.h"
-
CocoaPods install
#import <AFNetworking-PromiseKit/AFNetworking-PromiseKit.h>
NSMutableURLRequest *request = [[AFClient sharedClient] requestWithMethod:@"GET" path:@"/test.json" parameters:nil];
[AFJSONRequestOperation promise:request].then(^(AFHTTPRequestOperation *operation, id JSON){
NSLog(@"Received: %@", JSON);
}).catch(^(NSError *error){
NSLog(@"Received an error: %@", error);
});
AFNetworking-PromiseKit is licensed under the MIT license. Please see the license for more information.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request