转:AFNetworking 与 UIKit+AFNetworking 详解
资料来源 : http://www.aiuxian.com/article/p-1537192.html
http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html http://www.aiuxian.com/article/p-542408.html
- #import
-
- #import
-
- #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
-
- #import
-
- @class AFURLConnectionOperation;
-
- /**
- This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a request operation or session task.
- */
- @interface UIActivityIndicatorView (AFNetworking)
-
- ///----------------------------------
- /// @name Animating for Session Tasks
- ///----------------------------------
-
- /**
- Binds the animating state to the state of the specified task.
-
- @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
- */
- #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
- - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task;
- #endif
-
- ///---------------------------------------
- /// @name Animating for Request Operations
- ///---------------------------------------
-
- /**
- Binds the animating state to the execution state of the specified operation.
-
- @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled.
- */
- - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation;
-
- @end
这个类别为网络请求的状态显示增加了两个方法,通过这两个方法可以根据当前任务的状态或操作的状态决定网络请求状态的显示与隐藏。
链接地址4)UIAlertView+AFNetworking.h
和上面的类别类似,不过这个类别主要是为 UIAlertView 增加了几个方法,当相关的网络任务和请求操作发生错误时,会弹出一个 UIAlertView ,虽然 iOS7 的 UIAlertView 看上去温柔很多,很我个人还是很讨厌这个粗暴的弹出提示,我同样不喜欢转圈圈的等待提示。
链接地址5)UIButton+AFNetworking.h
这个类别主要是为 UIButton 增加了异步获取网络图片的类别方法,用过类似 EGOImageView 的应该很容易理解。
链接地址6)UIImageView+AFNetworking.h
说曹操曹操到,这个就是 EGOImageView 的 AFNetworking 版。
链接地址7)UIProgressView+AFNetworking.h
同 UIActivityIndicatorView+AFNetworking ,只是这个类别是针对 UIProgressView 的。
链接地址8)UIRefreshControl+AFNetworking.h
同 UIActivityIndicatorView+AFNetworking ,只是这个类别是针对 UIRefreshControl 的。UIRefreshControl 是 iOS7 新增加的下拉刷新显示控件,通过这个类别可以根据网络的行为和请求结果决定 UIRefreshControl 的显示状态。
链接地址9)UIWebView+AFNetworking.h
为 UIWebView 的载入请求增加了几个类别方法,便于决定请求成功失败如何显示,以及请求过程中等待状态的显示等。
链接地址三、 一点总结
粗略的浏览完 AFNetworking 的源代码之后深刻的感受了一下那么一句话:“我们不生产代码,我们只是 Github 的搬运工!”。自省一下,继续努力!
http://www.aiuxian.com/article/p-1715579.html