日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

回头看看NSURLConnection

發布時間:2024/7/23 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 回头看看NSURLConnection 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、基礎代理
1.使用場景網絡錯誤提示,以及證書使用控制。
2.協議內容@protocol NSURLConnectionDelegate <NSObject>@optional- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection;是否使用證書- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;為指定的身份驗證發送請求@end
二、數據代理
1.使用場景:用于監測數據的發送和接受,請求狀態,緩存控制。
2.協議內容@protocol NSURLConnectionDataDelegate <NSURLConnectionDelegate>@optional- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response;- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;- (NSInputStream *)connection:(NSURLConnection *)connection needNewBodyStream:(NSURLRequest *)request;- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?totalBytesWritten:(NSInteger)totalBytesWritten? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse;- (void)connectionDidFinishLoading:(NSURLConnection *)connection;@end
三、下載代理:
1.使用場景:特意為Newsstand下載雜志數據而設立。? 使用NKAssetDownload的downloadWithDelegate:(id<NSURLConnectionDownloadDelegate>)delegate方法時使用。
2.協議內容:@protocol NSURLConnectionDownloadDelegate <NSURLConnectionDelegate>@optional- (void)connection:(NSURLConnection *)connection didWriteData:(long long)bytesWritten totalBytesWritten:(long long)totalBytesWritten expectedTotalBytes:(long long) expectedTotalBytes;- (void)connectionDidResumeDownloading:(NSURLConnection *)connection totalBytesWritten:(long long)totalBytesWritten expectedTotalBytes:(long long) expectedTotalBytes;@required- (void)connectionDidFinishDownloading:(NSURLConnection *)connection destinationURL:(NSURL *) destinationURL;@end
四、方便發送同步請求的方法
+ (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NSURLResponse **)response error:(NSError **)error;
五、方便發送異步請求的方法
+ (void)sendAsynchronousRequest:(NSURLRequest*) request? ? ? ? ? ? ? ? ? ? ? ? ? queue:(NSOperationQueue*) queue? ? ? ? ? ? ? completionHandler:(void (^)(NSURLResponse* response, NSData* data, NSError* connectionError)) handler NS_AVAILABLE(10_7, 5_0);

總結

以上是生活随笔為你收集整理的回头看看NSURLConnection的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。