https://github.com/cmckni3/afnetworking-promisekit
AFNetworking category for PromiseKit
https://github.com/cmckni3/afnetworking-promisekit
afnetworking ios promisekit
Last synced: about 1 year ago
JSON representation
AFNetworking category for PromiseKit
- Host: GitHub
- URL: https://github.com/cmckni3/afnetworking-promisekit
- Owner: cmckni3
- License: mit
- Created: 2015-06-02T00:47:35.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-02-16T16:44:53.000Z (over 10 years ago)
- Last Synced: 2024-10-06T12:41:57.279Z (over 1 year ago)
- Topics: afnetworking, ios, promisekit
- Language: Objective-C
- Homepage:
- Size: 10.7 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# AFNetworking-PromiseKit
[](http://cocoapods.org/pods/AFNetworking-PromiseKit)
[](http://cocoapods.org/pods/AFNetworking-PromiseKit)
[](http://cocoapods.org/pods/AFNetworking-PromiseKit)
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.
## Requirements
* [AFNetworking 1.x](https://github.com/AFNetworking/AFNetworking)
* [PromiseKit 1.x](https://github.com/mxcl/PromiseKit)
### Supported Platforms
* iOS 6.0+
* OS X 10.7+
## Installation
### Install via [CocoaPods](https://github.com/cocoapods/cocoapods)
* Add the library to `Podfile`
```ruby
platform :ios, '6.0'
pod 'AFNetworking-PromiseKit'
```
* Install pod
```bash
pod install
```
### Manual
* Drop `AFHTTPRequestOperation+PromiseKit.h`, `AFHTTPRequestOperation+PromiseKit.m`,
and `AFNetworking-PromiseKit.h` into an Xcode project with AFNetworking
and set the appropriate targets.
## Usage
### Import the category
* Manual install
```objective-c
#import "AFNetworking-PromiseKit.h"
```
* CocoaPods install
```objective-c
#import
```
### Call a typical `AFHTTPRequestOperation` operation class method and use the resulting promise.
```objective-c
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);
});
```
## License
[AFNetworking-PromiseKit](https://github.com/cmckni3/AFNetworking-PromiseKit) is licensed under the MIT license. Please see the [license](MIT-LICENSE) for more information.
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request