afnetworking-racextensions

Welcome to AFNetworking-RACExtensions

AFNetworking-RACExtensions is a collection of ReactiveCocoa extensions for AFNetworking. This library provides convenient ReactiveCocoa signal producers for AFNetworking operations, making it easier to handle asynchronous network requests in your ReactiveCocoa-based code.

Installation

To install AFNetworking-RACExtensions, you can use CocoaPods. Simply add the following line to your Podfile:

pod 'AFNetworking-RACExtensions'

Usage

AFNetworking-RACExtensions adds ReactiveCocoa signal producers to AFNetworking operations. These signal producers emit instances of RACTuple, which contain the operation’s response object and any associated error.

Examples

Example 1: Making a GET request


AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[[operation rac_start] subscribeNext:^(RACTuple *responseTuple) {
NSHTTPURLResponse *response = responseTuple.first;
NSData *responseData = responseTuple.second;
// Process the response data
} error:^(NSError *error) {
// Handle the error
}];

Example 2: Making a POST request


AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[[operation rac_start] subscribeNext:^(RACTuple *responseTuple) {
NSHTTPURLResponse *response = responseTuple.first;
NSData *responseData = responseTuple.second;
// Process the response data
} error:^(NSError *error) {
// Handle the error
}];

API Reference

The following ReactiveCocoa signal producers are available in AFNetworking-RACExtensions:

Method Description
rac_start Returns a signal producer for starting the request operation.
rac_uploadProgress Returns a signal producer for monitoring the upload progress of an operation.
rac_downloadProgress Returns a signal producer for monitoring the download progress of an operation.

Contributing

We welcome contributions to AFNetworking-RACExtensions! If you find any issues or have ideas for improvement, please submit a pull request or open an issue on our GitHub repository.

License

AFNetworking-RACExtensions is available under the MIT license. See the LICENSE file for more information.