美文网首页
AFURLSessionManager

AFURLSessionManager

作者: wyymaomi | 来源:发表于2017-01-16 14:26 被阅读59次

    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: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.

    相关文章

      网友评论

          本文标题:AFURLSessionManager

          本文链接:https://www.haomeiwen.com/subject/zucpbttx.html