|
|
@@ -145,6 +145,9 @@ extension UIButton {
|
|
|
- parameter completionHandler: Called when the image retrieved and set.
|
|
|
|
|
|
- returns: A task represents the retrieving process.
|
|
|
+
|
|
|
+ - note: `completionHandler` will be invoked in main thread.
|
|
|
+ The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method.
|
|
|
*/
|
|
|
public func kf_setImageWithResource(resource: Resource,
|
|
|
forState state: UIControlState,
|
|
|
@@ -165,6 +168,9 @@ extension UIButton {
|
|
|
- parameter completionHandler: Called when the image retrieved and set.
|
|
|
|
|
|
- returns: A task represents the retrieving process.
|
|
|
+
|
|
|
+ - note: `completionHandler` will be invoked in main thread.
|
|
|
+ The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method.
|
|
|
*/
|
|
|
public func kf_setImageWithURL(URL: NSURL,
|
|
|
forState state: UIControlState,
|
|
|
@@ -187,6 +193,9 @@ extension UIButton {
|
|
|
- parameter completionHandler: Called when the image retrieved and set.
|
|
|
|
|
|
- returns: A task represents the retrieving process.
|
|
|
+
|
|
|
+ - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread.
|
|
|
+ The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method.
|
|
|
*/
|
|
|
public func kf_setImageWithResource(resource: Resource,
|
|
|
forState state: UIControlState,
|
|
|
@@ -200,14 +209,11 @@ extension UIButton {
|
|
|
let task = KingfisherManager.sharedManager.retrieveImageWithResource(resource, optionsInfo: optionsInfo,
|
|
|
progressBlock: { receivedSize, totalSize in
|
|
|
if let progressBlock = progressBlock {
|
|
|
- dispatch_async(dispatch_get_main_queue(), { () -> Void in
|
|
|
- progressBlock(receivedSize: receivedSize, totalSize: totalSize)
|
|
|
- })
|
|
|
+ progressBlock(receivedSize: receivedSize, totalSize: totalSize)
|
|
|
}
|
|
|
},
|
|
|
completionHandler: {[weak self] image, error, cacheType, imageURL in
|
|
|
-
|
|
|
- dispatch_async_safely_main_queue {
|
|
|
+ dispatch_async_safely_to_main_queue {
|
|
|
if let sSelf = self {
|
|
|
|
|
|
sSelf.kf_setImageTask(nil)
|
|
|
@@ -235,6 +241,9 @@ extension UIButton {
|
|
|
- parameter completionHandler: Called when the image retrieved and set.
|
|
|
|
|
|
- returns: A task represents the retrieving process.
|
|
|
+
|
|
|
+ - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread.
|
|
|
+ The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method.
|
|
|
*/
|
|
|
public func kf_setImageWithURL(URL: NSURL,
|
|
|
forState state: UIControlState,
|
|
|
@@ -410,6 +419,9 @@ extension UIButton {
|
|
|
- parameter completionHandler: Called when the image retrieved and set.
|
|
|
|
|
|
- returns: A task represents the retrieving process.
|
|
|
+
|
|
|
+ - note: `completionHandler` will be invoked in main thread.
|
|
|
+ The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method.
|
|
|
*/
|
|
|
public func kf_setBackgroundImageWithResource(resource: Resource,
|
|
|
forState state: UIControlState,
|
|
|
@@ -430,6 +442,9 @@ extension UIButton {
|
|
|
- parameter completionHandler: Called when the image retrieved and set.
|
|
|
|
|
|
- returns: A task represents the retrieving process.
|
|
|
+
|
|
|
+ - note: `completionHandler` will be invoked in main thread.
|
|
|
+ The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method.
|
|
|
*/
|
|
|
public func kf_setBackgroundImageWithURL(URL: NSURL,
|
|
|
forState state: UIControlState,
|
|
|
@@ -452,6 +467,9 @@ extension UIButton {
|
|
|
- parameter completionHandler: Called when the image retrieved and set.
|
|
|
|
|
|
- returns: A task represents the retrieving process.
|
|
|
+
|
|
|
+ - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread.
|
|
|
+ The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method.
|
|
|
*/
|
|
|
public func kf_setBackgroundImageWithResource(resource: Resource,
|
|
|
forState state: UIControlState,
|
|
|
@@ -465,14 +483,11 @@ extension UIButton {
|
|
|
let task = KingfisherManager.sharedManager.retrieveImageWithResource(resource, optionsInfo: optionsInfo,
|
|
|
progressBlock: { receivedSize, totalSize in
|
|
|
if let progressBlock = progressBlock {
|
|
|
- dispatch_async(dispatch_get_main_queue(), { () -> Void in
|
|
|
- progressBlock(receivedSize: receivedSize, totalSize: totalSize)
|
|
|
- })
|
|
|
+ progressBlock(receivedSize: receivedSize, totalSize: totalSize)
|
|
|
}
|
|
|
},
|
|
|
completionHandler: { [weak self] image, error, cacheType, imageURL in
|
|
|
- dispatch_async_safely_main_queue {
|
|
|
-
|
|
|
+ dispatch_async_safely_to_main_queue {
|
|
|
if let sSelf = self {
|
|
|
|
|
|
sSelf.kf_setBackgroundImageTask(nil)
|
|
|
@@ -501,6 +516,9 @@ extension UIButton {
|
|
|
- parameter completionHandler: Called when the image retrieved and set.
|
|
|
|
|
|
- returns: A task represents the retrieving process.
|
|
|
+
|
|
|
+ - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread.
|
|
|
+ The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method.
|
|
|
*/
|
|
|
public func kf_setBackgroundImageWithURL(URL: NSURL,
|
|
|
forState state: UIControlState,
|