| Core |
| AFURLConnectionOperation |
An NSOperation that implements the NSURLConnection delegate methods. |
| HTTP Requests |
| AFHTTPRequestOperation |
A subclass of AFURLConnectionOperation for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request. |
| AFJSONRequestOperation |
A subclass of AFHTTPRequestOperation for downloading and working with JSON response data. |
| AFXMLRequestOperation |
A subclass of AFHTTPRequestOperation for downloading and working with XML response data. |
| AFPropertyListRequestOperation |
A subclass of AFHTTPRequestOperation for downloading and deserializing objects with property list response data. |
| HTTP Client |
| AFHTTPClient |
Captures the common patterns of communicating with an web application over HTTP, including:
- Making requests from relative paths of a base URL
- Setting HTTP headers to be added automatically to requests
- Authenticating requests with HTTP Basic credentials or an OAuth token
- Managing an NSOperationQueue for requests made by the client
- Generating query strings or HTTP bodies from an NSDictionary
- Constructing multipart form requests
- Automatically parsing HTTP response data into its corresponding object representation
- Monitoring and responding to changes in network reachability
|
| Images |
| AFImageRequestOperation |
A subclass of AFHTTPRequestOperation for downloading an processing images. |
| UIImageView+AFNetworking |
Adds methods to `UIImageView` for loading remote images asynchronously from a URL. |
## Example Usage
### XML Request
``` objective-c
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://api.flickr.com/services/rest/?method=flickr.groups.browse&api_key=b6300e17ad3c506e706cb0072175d047&cat_id=34427469792%40N01&format=rest"]];
AFXMLRequestOperation *operation = [AFXMLRequestOperation XMLParserRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser) {
XMLParser.delegate = self;
[XMLParser parse];
} failure:nil];
[operation start];
```
### Image Request
``` objective-c
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];
[imageView setImageWithURL:[NSURL URLWithString:@"http://i.imgur.com/r4uwx.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]];
```
### API Client Request
``` objective-c
// AFGowallaAPIClient is a subclass of AFHTTPClient, which defines the base URL and default HTTP headers for NSURLRequests it creates
[[AFGowallaAPIClient sharedClient] getPath:@"/spots/9223" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Name: %@", [responseObject valueForKeyPath:@"name"]);
NSLog(@"Address: %@", [responseObject valueForKeyPath:@"address.street_address"]);
} failure:nil];
```
### File Upload with Progress Callback
``` objective-c
NSURL *url = [NSURL URLWithString:@"http://api-base-url.com"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"avatar.jpg"], 0.5);
NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"/upload" parameters:nil constructingBodyWithBlock: ^(id