TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
AYNetworking is a set of category with API methods to make it easier to handle requests and response with AFNetworking Framework.
AYNetworking extent AFHTTPClient and AFHTTPRequestOperation API of the AFNetworking Framework.
Inspired by LRResty
When you will use the AYNetworking Framework in your code you can just add the import command below. This will import AFNetworking for you too.
#import <AYNetworking/AYNetworking.h>
First you need a AFHTTPClient class based client.
AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://base.url"]];
To send a request with blocks you can just use the code below.
[client get:@"resource"
success:^(AFHTTPRequestOperation *operation, id response) {
// handle the response...
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// handle the error...
}
];
The same for: post, delete, patch and put.
if your request need parameters or headers you can call it like below:
[client get:@"resource" parameters:@{@"": @""} headers:@{@"": @""}
success:^(AFHTTPRequestOperation *operation, id response) {
// handle the response...
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// handle the error...
}
];
If you want modify the AFHTTPRequestOperation before the operation start to send the request you can use the code below.
[client willStartRequestOperation:^(AFHTTPRequestOperation *operation) {
// modify the AFHTTPRequestOperation...
}];
To send a request with delegate you can just use the code below.
[client get:@"resource" delegate:self];
The delegate protocol methods to handle the response.
- (void)client:(AFHTTPClient *)client requestOperation:(AFHTTPRequestOperation *)operation didSuccessfulWithObject:(id)response
{
// handle the response...
}
- (void)client:(AFHTTPClient *)client requestOperation:(AFHTTPRequestOperation *)operation didFailWithError:(NSError *)error
{
// handle the error...
}
synchronous send request and handle response looks like below.
AFHTTPRequestOperation *operation = [client get:@"resource"];
if (operation.isSuccess){
// handle the response...
// operation.responseObject;
}
if (operation.isFailure) {
// handle the error...
// operation.error;
}
✓ Block API
✓ Delegate API
✓ Synchronous API
✗ Documentation
✗ UnitTest & Continuous Integration Build