<p align="center" >
<img src="https://raw.github.com/AFNetworking/AFNetworking/assets/afnetworking-logo.png" alt="AFNetworking" title="AFNetworking">
</p>
[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.svg)](https://travis-ci.org/AFNetworking/AFNetworking)
AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of the [Foundation URL Loading System](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use.
Perhaps 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.
Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did!
## How To Get Started
- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/archive/master.zip) and try out the included Mac and iPhone example apps
- 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 on the Wiki](https://github.com/AFNetworking/AFNetworking/wiki)
- Check out the [documentation](http://cocoadocs.org/docsets/AFNetworking/) for a comprehensive look at all of the APIs available in AFNetworking
- Read the [AFNetworking 2.0 Migration Guide](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-2.0-Migration-Guide) for an overview of the architectural changes from 1.0.
## Communication
- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). (Tag 'afnetworking')
- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking).
- If you **found a bug**, open an issue.
- If you **have a feature request**, open an issue.
- If you **want to contribute**, submit a pull request.
### Installation with CocoaPods
[CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AFNetworking in your projects. See the ["Getting Started" guide for more information](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking).
#### Podfile
```ruby
platform :ios, '7.0'
pod "AFNetworking", "~> 2.0"
```
## Requirements
| AFNetworking Version | Minimum iOS Target | Minimum OS X Target | Notes |
|:--------------------:|:---------------------------:|:----------------------------:|:-------------------------------------------------------------------------:|
| 2.x | iOS 6 | OS X 10.8 | Xcode 5 is required. `AFHTTPSessionManager` requires iOS 7 or OS X 10.9. |
| [1.x](https://github.com/AFNetworking/AFNetworking/tree/1.x) | iOS 5 | Mac OS X 10.7 | |
| [0.10.x](https://github.com/AFNetworking/AFNetworking/tree/0.10.x) | iOS 4 | Mac OS X 10.6 | |
(OS X projects must support [64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)).
## Architecture
### NSURLConnection
- `AFURLConnectionOperation`
- `AFHTTPRequestOperation`
- `AFHTTPRequestOperationManager`
### NSURLSession _(iOS 7 / Mac OS X 10.9)_
- `AFURLSessionManager`
- `AFHTTPSessionManager`
### Serialization
* `<AFURLRequestSerialization>`
- `AFHTTPRequestSerializer`
- `AFJSONRequestSerializer`
- `AFPropertyListRequestSerializer`
* `<AFURLResponseSerialization>`
- `AFHTTPResponseSerializer`
- `AFJSONResponseSerializer`
- `AFXMLParserResponseSerializer`
- `AFXMLDocumentResponseSerializer` _(Mac OS X)_
- `AFPropertyListResponseSerializer`
- `AFImageResponseSerializer`
- `AFCompoundResponseSerializer`
### Additional Functionality
- `AFSecurityPolicy`
- `AFNetworkReachabilityManager`
## Usage
### HTTP Request Operation Manager
`AFHTTPRequestOperationManager` encapsulates the common patterns of communicating with a web application over HTTP, including request creation, response serialization, network reachability monitoring, and security, as well as request operation management.
#### `GET` Request
```objective-c
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://example.com/resources.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
```
#### `POST` URL-Form-Encoded Request
```objective-c
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"foo": @"bar"};
[manager POST:@"http://example.com/resources.json" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
```
#### `POST` Multi-Part Request
```objective-c
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"foo": @"bar"};
NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"];
[manager POST:@"http://example.com/resources.json" parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileURL:filePath name:@"image" error:nil];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
```
---
### AFURLSessionManager
`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to `<NSURLSessionTaskDelegate>`, `<NSURLSessionDataDelegate>`, `<NSURLSessionDownloadDelegate>`, and `<NSURLSessionDelegate>`.
#### Creating a Download Task
```objective-c
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
NSURL *URL = [NSURL URLWithString:@"http://example.com/download.zip"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
NSLog(@"File downloaded to: %@", filePath);
}];
[downloadTask resume];
```
#### Creating an Upload Task
```objective-c
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"];
NSURLRequest *request = [NSURLRequest req
没有合适的资源?快使用搜索试试~ 我知道了~
AFNetworking网络库
共105个文件
m:32个
h:18个
cer:15个
1星 需积分: 10 80 下载量 125 浏览量
2014-09-08
08:24:21
上传
评论
收藏 267KB ZIP 举报
温馨提示
AFNetworking是一个讨人喜欢的网络库,适用于iOS以及Mac OS X. 它构建于在NSURLConnection, NSOperation, 以及其他熟悉的Foundation技术之上. 它拥有良好的架构,丰富的api,以及模块化构建方式,使得使用起来非常轻松.例如,他可以使用很轻松的方式从一个url来得到json数据
资源推荐
资源详情
资源评论
收起资源包目录
AFNetworking网络库 (105个子文件)
adn_1.cer 2KB
digicert_ca_3.cer 2KB
adn.cer 1KB
adn_0.cer 1KB
httpbinorg_11212014.cer 1KB
httpbin_0.cer 1KB
httpbin_1.cer 985B
Rapid_SSL_CA.cer 985B
root_ca.cer 969B
adn_2.cer 969B
httpbin_2.cer 856B
Geotrust_Root_CA.cer 856B
AltName.cer 766B
foobar.com.cer 747B
NoDomains.cer 747B
CHANGES 55KB
.DS_Store 6KB
AFNetworking Example.entitlements 350B
.gitignore 321B
UIButton+AFNetworking.h 9KB
UIImageView+AFNetworking.h 7KB
UIWebView+AFNetworking.h 6KB
UIAlertView+AFNetworking.h 5KB
AFNetworkActivityIndicatorManager.h 4KB
UIProgressView+AFNetworking.h 3KB
UIActivityIndicatorView+AFNetworking.h 2KB
UIRefreshControl+AFNetworking.h 2KB
AppDelegate.h 2KB
UIKit+AFNetworking.h 2KB
User.h 2KB
AFMockURLProtocol.h 2KB
Post.h 2KB
AFTestCase.h 1KB
AFNetworkingTests.h 1KB
PostTableViewCell.h 1KB
AFAppDotNetAPIClient.h 1KB
GlobalTimelineViewController.h 1KB
LICENSE 1KB
AFSecurityPolicyTests.m 25KB
AFHTTPRequestOperationTests.m 18KB
AFHTTPClientTests.m 16KB
AFURLConnectionOperationTests.m 16KB
UIButton+AFNetworking.m 10KB
AFHTTPRequestOperationTests.m 10KB
UIProgressView+AFNetworking.m 8KB
UIImageView+AFNetworking.m 8KB
AFHTTPRequestSerializationTests.m 7KB
AFImageRequestOperationTests.m 7KB
UIWebView+AFNetworking.m 6KB
AFNetworkActivityIndicatorManager.m 6KB
AFJSONSerializationTests.m 6KB
UIAlertView+AFNetworking.m 6KB
AFJSONRequestOperationTests.m 5KB
AFNetworkActivityManagerTests.m 4KB
User.m 4KB
UIActivityIndicatorView+AFNetworking.m 4KB
UIRefreshControl+AFNetworking.m 4KB
AFHTTPSessionManagerTests.m 4KB
AppDelegate.m 4KB
GlobalTimelineViewController.m 4KB
AFMockURLProtocol.m 3KB
AFHTTPResponseSerializationTests.m 3KB
AFURLSessionManagerTests.m 3KB
PostTableViewCell.m 3KB
Post.m 2KB
AFPropertyListResponseSerializerTests.m 2KB
AFAppDotNetAPIClient.m 2KB
AFNetworkingTests.m 2KB
main.m 2KB
AFTestCase.m 1KB
README.md 16KB
CONTRIBUTING.md 715B
project.pbxproj 41KB
project.pbxproj 39KB
project.pbxproj 22KB
Prefix.pch 580B
AFNetworking-Prefix.pch 481B
iOS Tests-Prefix.pch 210B
OS X Tests-Prefix.pch 182B
iOS-Info.plist 2KB
Mac-Info.plist 1KB
iOS Tests-Info.plist 706B
OS X Tests-Info.plist 706B
AFNetworkingTests-Info.plist 696B
Default-568h@2x.png 18KB
Icon@2x.png 10KB
Icon.png 6KB
Default@2x.png 5KB
profile-image-placeholder@2x.png 3KB
profile-image-placeholder.png 1KB
Default.png 942B
Podfile 358B
AFNetworking.podspec 2KB
Rakefile 1KB
InfoPlist.strings 45B
InfoPlist.strings 45B
OS X Tests.xcscheme 3KB
iOS Tests.xcscheme 3KB
contents.xcworkspacedata 5KB
contents.xcworkspacedata 169B
共 105 条
- 1
- 2
资源评论
- qq_332369882016-09-25勇者不错。
yyt1992
- 粉丝: 6
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功