{"id":15048272,"url":"https://github.com/github/afnetworking","last_synced_at":"2026-01-11T03:51:00.763Z","repository":{"id":20591403,"uuid":"23872149","full_name":"github/AFNetworking","owner":"github","description":"A delightful iOS and OS X networking framework","archived":true,"fork":true,"pushed_at":"2015-01-19T18:32:46.000Z","size":5435,"stargazers_count":28,"open_issues_count":0,"forks_count":19,"subscribers_count":30,"default_branch":"octokit-pin","last_synced_at":"2024-09-29T00:20:57.224Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://afnetworking.com","language":"Objective-C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"AFNetworking/AFNetworking","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/github.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-10T11:34:28.000Z","updated_at":"2024-07-31T03:22:04.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/github/AFNetworking","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2FAFNetworking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2FAFNetworking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2FAFNetworking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2FAFNetworking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/github","download_url":"https://codeload.github.com/github/AFNetworking/tar.gz/refs/heads/octokit-pin","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235232474,"owners_count":18957057,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T21:10:03.030Z","updated_at":"2025-10-04T08:31:09.724Z","avatar_url":"https://github.com/github.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\" \u003e\n  \u003cimg src=\"https://raw.github.com/AFNetworking/AFNetworking/assets/afnetworking-logo.png\" alt=\"AFNetworking\" title=\"AFNetworking\"\u003e\n\u003c/p\u003e\n\n[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.png?branch=master)](https://travis-ci.org/AFNetworking/AFNetworking)\n\nAFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of [NSURLConnection](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html), [NSOperation](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperation_class/Reference/Reference.html), and other familiar Foundation technologies. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. For example, here's how easy it is to get JSON from a URL:\n\n```objective-c\nNSURL *url = [NSURL URLWithString:@\"https://alpha-api.app.net/stream/0/posts/stream/global\"];\nNSURLRequest *request = [NSURLRequest requestWithURL:url];\nAFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {\n    NSLog(@\"App.net Global Stream: %@\", JSON);\n} failure:nil];\n[operation start];\n```\n\nPerhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac.\n\nChoose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did!\n\n## How To Get Started\n\n- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/zipball/master) and try out the included Mac and iPhone example apps\n- Read the [\"Getting Started\" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles in the wiki](https://github.com/AFNetworking/AFNetworking/wiki)\n- Check out the [complete documentation](http://cocoadocs.org/docsets/AFNetworking/) for a comprehensive look at the APIs available in AFNetworking\n- Watch the [NSScreencast episode about AFNetworking](http://nsscreencast.com/episodes/6-afnetworking) for a quick introduction to how to use it in your application\n- Questions? [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking) is the best place to find answers\n\n## Overview\n\nAFNetworking is architected to be as small and modular as possible, in order to make it simple to use and extend.\n\n\u003ctable\u003e\n  \u003ctr\u003e\u003cth colspan=\"2\" style=\"text-align:center;\"\u003eCore\u003c/th\u003e\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFURLConnectionOperation.html\"\u003eAFURLConnectionOperation\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003eAn \u003ctt\u003eNSOperation\u003c/tt\u003e that implements the \u003ctt\u003eNSURLConnection\u003c/tt\u003e delegate methods.\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\u003cth colspan=\"2\" style=\"text-align:center;\"\u003eHTTP Requests\u003c/th\u003e\u003c/tr\u003e\n\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFHTTPRequestOperation.html\"\u003eAFHTTPRequestOperation\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003eA subclass of \u003ctt\u003eAFURLConnectionOperation\u003c/tt\u003e 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.\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFJSONRequestOperation.html\"\u003eAFJSONRequestOperation\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003eA subclass of \u003ctt\u003eAFHTTPRequestOperation\u003c/tt\u003e for downloading and working with JSON response data.\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFXMLRequestOperation.html\"\u003eAFXMLRequestOperation\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003eA subclass of \u003ctt\u003eAFHTTPRequestOperation\u003c/tt\u003e for downloading and working with XML response data.\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFPropertyListRequestOperation.html\"\u003eAFPropertyListRequestOperation\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003eA subclass of \u003ctt\u003eAFHTTPRequestOperation\u003c/tt\u003e for downloading and deserializing objects with \u003ca href=\"http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/PropertyLists/index.html\"\u003eproperty list\u003c/a\u003e response data.\u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\u003cth colspan=\"2\" style=\"text-align:center;\"\u003eHTTP Client\u003c/th\u003e\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFHTTPClient.html\"\u003eAFHTTPClient\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003e\n      Captures the common patterns of communicating with an web application over HTTP, including:\n\n      \u003cul\u003e\n        \u003cli\u003eMaking requests from relative paths of a base URL\u003c/li\u003e\n        \u003cli\u003eSetting HTTP headers to be added automatically to requests\u003c/li\u003e\n        \u003cli\u003eAuthenticating requests with HTTP Basic credentials or an OAuth token\u003c/li\u003e\n        \u003cli\u003eManaging an \u003ctt\u003eNSOperationQueue\u003c/tt\u003e for requests made by the client\u003c/li\u003e\n        \u003cli\u003eGenerating query strings or HTTP bodies from an \u003ctt\u003eNSDictionary\u003c/tt\u003e\u003c/li\u003e\n        \u003cli\u003eConstructing multipart form requests\u003c/li\u003e\n        \u003cli\u003eAutomatically parsing HTTP response data into its corresponding object representation\u003c/li\u003e\n        \u003cli\u003eMonitoring and responding to changes in network reachability\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\u003cth colspan=\"2\" style=\"text-align:center;\"\u003eImages\u003c/th\u003e\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFImageRequestOperation.html\"\u003eAFImageRequestOperation\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003eA subclass of \u003ctt\u003eAFHTTPRequestOperation\u003c/tt\u003e for downloading and processing images.\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ca href=\"http://afnetworking.github.com/AFNetworking/Categories/UIImageView+AFNetworking.html\"\u003eUIImageView+AFNetworking\u003c/a\u003e\u003c/td\u003e\n    \u003ctd\u003eAdds methods to \u003ctt\u003eUIImageView\u003c/tt\u003e for loading remote images asynchronously from a URL.\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## Example Usage\n\n### XML Request\n\n```objective-c\nNSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@\"http://api.flickr.com/services/rest/?method=flickr.groups.browse\u0026api_key=b6300e17ad3c506e706cb0072175d047\u0026cat_id=34427469792%40N01\u0026format=rest\"]];\nAFXMLRequestOperation *operation = [AFXMLRequestOperation XMLParserRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser) {\n  XMLParser.delegate = self;\n  [XMLParser parse];\n} failure:nil];\n[operation start];\n```\n\n### Image Request\n\n```objective-c\nUIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];\n[imageView setImageWithURL:[NSURL URLWithString:@\"http://i.imgur.com/r4uwx.jpg\"] placeholderImage:[UIImage imageNamed:@\"placeholder-avatar\"]];\n```\n\n### API Client Request\n\n```objective-c\n// AFAppDotNetAPIClient is a subclass of AFHTTPClient, which defines the base URL and default HTTP headers for NSURLRequests it creates\n[[AFAppDotNetAPIClient sharedClient] getPath:@\"stream/0/posts/stream/global\" parameters:nil success:^(AFHTTPRequestOperation *operation, id JSON) {\n    NSLog(@\"App.net Global Stream: %@\", JSON);\n} failure:nil];\n```\n\n### File Upload with Progress Callback\n\n```objective-c\nNSURL *url = [NSURL URLWithString:@\"http://api-base-url.com\"];\nAFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];\nNSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@\"avatar.jpg\"], 0.5);\nNSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@\"POST\" path:@\"/upload\" parameters:nil constructingBodyWithBlock: ^(id \u003cAFMultipartFormData\u003eformData) {\n    [formData appendPartWithFileData:imageData name:@\"avatar\" fileName:@\"avatar.jpg\" mimeType:@\"image/jpeg\"];\n}];\n\nAFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];\n[operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {\n    NSLog(@\"Sent %lld of %lld bytes\", totalBytesWritten, totalBytesExpectedToWrite);\n}];\n[httpClient enqueueHTTPRequestOperation:operation];\n```\n\n### Streaming Request\n\n```objective-c\nNSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@\"http://localhost:8080/encode\"]];\n\nAFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];\noperation.inputStream = [NSInputStream inputStreamWithFileAtPath:[[NSBundle mainBundle] pathForResource:@\"large-image\" ofType:@\"tiff\"]];\noperation.outputStream = [NSOutputStream outputStreamToMemory];\n[operation start];\n```\n\n## Requirements\n\nAFNetworking 1.0 and higher requires either [iOS 5.0](http://developer.apple.com/library/ios/#releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS4.html) and above, or [Mac OS 10.7](http://developer.apple.com/library/mac/#releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_6.html#//apple_ref/doc/uid/TP40008898-SW7) ([64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)) and above.\n\nFor compatibility with iOS 4.3, use the latest 0.10.x release.\n\n### ARC\n\nAFNetworking uses ARC as of its 1.0 release.\n\nIf you are using AFNetworking 1.0 in your non-arc project, you will need to set a `-fobjc-arc` compiler flag on all of the AFNetworking source files. Conversely, if you are adding a pre-1.0 version of AFNetworking, you will need to set a `-fno-objc-arc` compiler flag.\n\nTo set a compiler flag in Xcode, go to your active target and select the \"Build Phases\" tab. Now select all AFNetworking source files, press Enter, insert `-fobjc-arc` or `-fno-objc-arc` and then \"Done\" to enable or disable ARC for AFNetworking.\n\n## Unit Tests\n\nAFNetworking includes a suite of unit tests within the Tests subdirectory. In order to run the unit tests, you must install the testing dependencies via CocoaPods. To do so:\n\n    $ gem install cocoapods # If necessary\n    $ cd Tests\n    $ pod install\n\nOnce CocoaPods has finished the installation, you can execute the test suite via the 'iOS Tests' and 'OS X Tests' schemes within Xcode.\n\n### Test Logging\n\nBy default, the unit tests do not emit any output during execution. For debugging purposes, it can be useful to enable logging of the requests and responses. Logging support is provided by the [AFHTTPRequestOperationLogger](https://github.com/AFNetworking/AFHTTPRequestOperationLogger) extension, which is installed via CocoaPods into the test targets. To enable logging, edit the test Scheme and add an environment variable named `AFTestsLoggingEnabled` with a value of `YES`.\n\n### Using xctool\n\nIf you wish to execute the tests from the command line or within a continuous integration environment, you will need to install [xctool](https://github.com/facebook/xctool). The recommended installation method is [Homebrew](http://mxcl.github.io/homebrew/).\n\nTo install the commandline testing support via Homebrew:\n\n    $ brew update\n    $ brew install xctool --HEAD\n\nOnce xctool is installed, you can execute the suite via `rake test`.\n\n## Credits\n\nAFNetworking was created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla).\n\nAFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/).\n\nAnd most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors).\n\n## Contact\n\nFollow AFNetworking on Twitter ([@AFNetworking](https://twitter.com/AFNetworking))\n\n### Creators\n\n[Mattt Thompson](http://github.com/mattt)\n[@mattt](https://twitter.com/mattt)\n\n[Scott Raymond](http://github.com/sco)\n[@sco](https://twitter.com/sco)\n\n## License\n\nAFNetworking is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fafnetworking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithub%2Fafnetworking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fafnetworking/lists"}