// AFURLSessionManager.h
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
#import "AFURLResponseSerialization.h"
#import "AFURLRequestSerialization.h"
#import "AFSecurityPolicy.h"
#if !TARGET_OS_WATCH
#import "AFNetworkReachabilityManager.h"
#endif
/**
`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to `<NSURLSessionTaskDelegate>`, `<NSURLSessionDataDelegate>`, `<NSURLSessionDownloadDelegate>`, and `<NSURLSessionDelegate>`.
## Subclassing Notes
This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead.
## NSURLSession & NSURLSessionTask Delegate Methods
`AFURLSessionManager` implements the following delegate methods:
### `NSURLSessionDelegate`
- `URLSession:didBecomeInvalidWithError:`
- `URLSession:didReceiveChallenge:completionHandler:`
- `URLSessionDidFinishEventsForBackgroundURLSession:`
### `NSURLSessionTaskDelegate`
- `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`
- `URLSession:task:didReceiveChallenge:completionHandler:`
- `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`
- `URLSession:task:needNewBodyStream:`
- `URLSession:task:didCompleteWithError:`
### `NSURLSessionDataDelegate`
- `URLSession:dataTask:didReceiveResponse:completionHandler:`
- `URLSession:dataTask:didBecomeDownloadTask:`
- `URLSession:dataTask:didReceiveData:`
- `URLSession:dataTask:willCacheResponse:completionHandler:`
### `NSURLSessionDownloadDelegate`
- `URLSession:downloadTask:didFinishDownloadingToURL:`
- `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`
- `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`
If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first.
## Network Reachability Monitoring
Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details.
## NSCoding Caveats
- Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`.
## NSCopying Caveats
- `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original.
- Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied.
@warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance.
*/
NS_ASSUME_NONNULL_BEGIN
@interface AFURLSessionManager : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate, NSSecureCoding, NSCopying>
/**
The managed session.
*/
@property (readonly, nonatomic, strong) NSURLSession *session;
/**
The operation queue on which delegate callbacks are run.
*/
@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue;
/**
Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`.
@warning `responseSerializer` must not be `nil`.
*/
@property (nonatomic, strong) id <AFURLResponseSerialization> responseSerializer;
///-------------------------------
/// @name Managing Security Policy
///-------------------------------
/**
The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified.
*/
@property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
#if !TARGET_OS_WATCH
///--------------------------------------
/// @name Monitoring Network Reachability
///--------------------------------------
/**
The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default.
*/
@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager;
#endif
///----------------------------
/// @name Getting Session Tasks
///----------------------------
/**
The data, upload, and download tasks currently run by the managed session.
*/
@property (readonly, nonatomic, strong) NSArray <NSURLSessionTask *> *tasks;
/**
The data tasks currently run by the managed session.
*/
@property (readonly, nonatomic, strong) NSArray <NSURLSessionDataTask *> *dataTasks;
/**
The upload tasks currently run by the managed session.
*/
@property (readonly, nonatomic, strong) NSArray <NSURLSessionUploadTask *> *uploadTasks;
/**
The download tasks currently run by the managed session.
*/
@property (readonly, nonatomic, strong) NSArray <NSURLSessionDownloadTask *> *downloadTasks;
///-------------------------------
/// @name Managing Callback Queues
///-------------------------------
/**
The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used.
*/
@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue;
/**
The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used.
*/
@property (nonatomic, strong, nullable) dispatch_group_t completionGroup;
///---------------------------------
/// @name Working Around System Bugs
///---------------------------------
/**
Whether to attempt to retry creation of upload tasks for background sessions when initial call returns `nil`. `NO` by default.
@bug As of iOS 7.0, there is a bug where upload tasks created for background tasks are sometimes `nil`. As a workaround, if this property is `YES`, AFNetworking will follow Apple's recommendation to try creating the task again.
@see https://github.com/AFNetworking/AFNetworking/issues/1675
*/
@property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions;
///---------------------
/// @name Initialization
///---------------------
/**
Creates and returns a manager for a session created with the specified configuration. This is the designated initializer.
@param configuration The configuration used to create the managed session.
@return A manager for a newly-created session.
*/
- (instancetype)initWithSession
没有合适的资源?快使用搜索试试~ 我知道了~
优雅的开发OC与Swift混编博客Demo
共70个文件
h:8个
m:6个
plist:4个
5星 · 超过95%的资源 需积分: 39 102 下载量 144 浏览量
2017-06-08
18:15:49
上传
评论 2
收藏 142KB ZIP 举报
温馨提示
下载,解压缩,打开YourApplication
资源推荐
资源详情
资源评论
收起资源包目录
OCFrameworkInSwift.zip (70个子文件)
OCFrameworkInSwift
YourApplication.xcodeproj
project.xcworkspace
contents.xcworkspacedata 160B
xcuserdata
Leo.xcuserdatad
UserInterfaceState.xcuserstate 18KB
project.pbxproj 14KB
xcuserdata
Leo.xcuserdatad
xcschemes
xcschememanagement.plist 487B
YourApplication.xcscheme 3KB
xcdebugger
Breakpoints_v2.xcbkptlist 777B
AFNSwift.xcodeproj
project.xcworkspace
contents.xcworkspacedata 153B
xcuserdata
Leo.xcuserdatad
UserInterfaceState.xcuserstate 13KB
project.pbxproj 17KB
xcuserdata
Leo.xcuserdatad
xcschemes
xcschememanagement.plist 480B
AFNSwift.xcscheme 3KB
.git
index 2KB
hooks
README.sample 177B
config 137B
description 73B
refs
tags
heads
master 41B
logs
refs
heads
master 169B
HEAD 169B
objects
fd
f3f97d1b6e9d8d29bb69a88c4d89ca752bd937 807B
36
d2c80d8893178d7e1f2964085b273959bfdc28 201B
ec
b65f64f2aa9d4cc5ca6e9f0f4cac073aa24a27 51B
d0
524738680109d9f0ca001dad7c9bbf563e898e 523B
ef
e6d036f817624654f77c4a91ae6f20b5ecbe9d 94B
3a100dbdcd861d63bfec071527fcac72fbc9db 134B
a8
f4fd46b0fef4c81ca97b7a011cdccc18de9087 131B
1b
9463fa658a98b185e8c890e7fae2159260720c 92B
27
3375fc70381bd2608e05c03e00ee09c42bdc58 783B
db
3f0ce163c8033a175d27de6a4e96aadc115625 59B
51
3c05d6f8e0e284828fa2d7b3356848676bc771 3KB
e9
065a5be082480db3a6900413fed1fcde9a6b1a 137B
b0
4364089fdc64fe3b81bcd41462dd55edb7a001 57B
c7
4643fe9483ce0e0ace401a508464e211fc1587 305B
34
e5ad56bccc3ce8725cea9902a6747393d2df41 305B
info
47
987bf3d9789033726a3ca4b65a1b46f3906ca2 307B
c4
13951788990c983231c02fb3b7ecdbf04a1bae 789B
pack
6a
b087da50452b401a91be27cc2a7edf20de768a 69B
25
6bd9fc66ce416bb3169cd9576edee73f90f709 3KB
04
6a64a6933b1339a9fa359f47f59d480e2d0af2 937B
45
c571968194843f79bc47506b54c0dcfbbaa696 146B
01
5fcc08db90999f31a3551073f9f041c432f91f 527B
d3
4878a34cbdcebabeb33ab407a1880321792266 110B
c9
5adc47f96e0f240be5609fd7c871756aef3650 57B
23
a1f6e48c7a54b119ff3e6c25efbd32373a016b 208B
info
exclude 40B
COMMIT_EDITMSG 15B
HEAD 23B
.DS_Store 6KB
YourApplication
ViewController.swift 557B
Assets.xcassets
AppIcon.appiconset
Contents.json 1KB
Base.lproj
LaunchScreen.storyboard 2KB
Main.storyboard 2KB
AppDelegate.swift 2KB
Info.plist 1KB
AFNSwift
AFNSwift.swift 867B
AFNetworking
AFURLSessionManager.m 53KB
AFURLResponseSerialization.m 26KB
AFURLSessionManager.h 29KB
AFSecurityPolicy.h 6KB
AFURLResponseSerialization.h 12KB
AFHTTPSessionManager.m 15KB
AFNetworkReachabilityManager.m 10KB
AFNetworkReachabilityManager.h 8KB
AFURLRequestSerialization.m 51KB
AFHTTPSessionManager.h 20KB
AFSecurityPolicy.m 12KB
AFNetworking.h 2KB
AFURLRequestSerialization.h 22KB
module.modulemap 200B
AFNSwift.h 483B
Info.plist 753B
共 70 条
- 1
资源评论
- yangketian2017-09-21不错,下下来试试看
- more2010wei2018-01-08先下载一下看看
- 愤奋鸟2019-03-25借鉴一下,重新下载
黄文臣
- 粉丝: 2228
- 资源: 33
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功