Browse Source

Add default value to optional parameters

onevcat 9 years ago
parent
commit
8e635ddcda
2 changed files with 24 additions and 24 deletions
  1. 8 8
      Sources/ImageView+Kingfisher.swift
  2. 16 16
      Sources/UIButton+Kingfisher.swift

+ 8 - 8
Sources/ImageView+Kingfisher.swift

@@ -57,10 +57,10 @@ extension ImageView {
      */
     
     public func kf_setImageWithURL(URL: NSURL,
-                                   placeholderImage: Image?,
-                                   optionsInfo: KingfisherOptionsInfo?,
-                                   progressBlock: DownloadProgressBlock?,
-                                   completionHandler: CompletionHandler?) -> RetrieveImageTask
+                                   placeholderImage: Image? = nil,
+                                   optionsInfo: KingfisherOptionsInfo? = nil,
+                                   progressBlock: DownloadProgressBlock? = nil,
+                                   completionHandler: CompletionHandler? = nil) -> RetrieveImageTask
     {
         return kf_setImageWithResource(Resource(downloadURL: URL),
                                        placeholderImage: placeholderImage,
@@ -85,10 +85,10 @@ extension ImageView {
      The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method.
     */
     public func kf_setImageWithResource(resource: Resource,
-                                placeholderImage: Image?,
-                                     optionsInfo: KingfisherOptionsInfo?,
-                                   progressBlock: DownloadProgressBlock?,
-                               completionHandler: CompletionHandler?) -> RetrieveImageTask
+                                placeholderImage: Image? = nil,
+                                     optionsInfo: KingfisherOptionsInfo? = nil,
+                                   progressBlock: DownloadProgressBlock? = nil,
+                               completionHandler: CompletionHandler? = nil) -> RetrieveImageTask
     {
         let showIndicatorWhenLoading = kf_showIndicatorWhenLoading
         var indicator: IndicatorView? = nil

+ 16 - 16
Sources/UIButton+Kingfisher.swift

@@ -49,10 +49,10 @@ extension UIButton {
      */
     public func kf_setImageWithURL(URL: NSURL,
                                    forState state: UIControlState,
-                                            placeholderImage: UIImage?,
-                                            optionsInfo: KingfisherOptionsInfo?,
-                                            progressBlock: DownloadProgressBlock?,
-                                            completionHandler: CompletionHandler?) -> RetrieveImageTask
+                                            placeholderImage: UIImage? = nil,
+                                            optionsInfo: KingfisherOptionsInfo? = nil,
+                                            progressBlock: DownloadProgressBlock? = nil,
+                                            completionHandler: CompletionHandler? = nil) -> RetrieveImageTask
     {
         return kf_setImageWithResource(Resource(downloadURL: URL),
                                        forState: state,
@@ -80,10 +80,10 @@ extension UIButton {
     */
     public func kf_setImageWithResource(resource: Resource,
                                   forState state: UIControlState,
-                                placeholderImage: UIImage?,
-                                     optionsInfo: KingfisherOptionsInfo?,
-                                   progressBlock: DownloadProgressBlock?,
-                               completionHandler: CompletionHandler?) -> RetrieveImageTask
+                                placeholderImage: UIImage? = nil,
+                                     optionsInfo: KingfisherOptionsInfo? = nil,
+                                   progressBlock: DownloadProgressBlock? = nil,
+                               completionHandler: CompletionHandler? = nil) -> RetrieveImageTask
     {
         setImage(placeholderImage, forState: state)
         kf_setWebURL(resource.downloadURL, forState: state)
@@ -176,10 +176,10 @@ extension UIButton {
      */
     public func kf_setBackgroundImageWithURL(URL: NSURL,
                                              forState state: UIControlState,
-                                                      placeholderImage: UIImage?,
-                                                      optionsInfo: KingfisherOptionsInfo?,
-                                                      progressBlock: DownloadProgressBlock?,
-                                                      completionHandler: CompletionHandler?) -> RetrieveImageTask
+                                                      placeholderImage: UIImage? = nil,
+                                                      optionsInfo: KingfisherOptionsInfo? = nil,
+                                                      progressBlock: DownloadProgressBlock? = nil,
+                                                      completionHandler: CompletionHandler? = nil) -> RetrieveImageTask
     {
         return kf_setBackgroundImageWithResource(Resource(downloadURL: URL),
                                                  forState: state,
@@ -208,10 +208,10 @@ extension UIButton {
     */
     public func kf_setBackgroundImageWithResource(resource: Resource,
                                             forState state: UIControlState,
-                                          placeholderImage: UIImage?,
-                                               optionsInfo: KingfisherOptionsInfo?,
-                                             progressBlock: DownloadProgressBlock?,
-                                         completionHandler: CompletionHandler?) -> RetrieveImageTask
+                                          placeholderImage: UIImage? = nil,
+                                               optionsInfo: KingfisherOptionsInfo? = nil,
+                                             progressBlock: DownloadProgressBlock? = nil,
+                                         completionHandler: CompletionHandler? = nil) -> RetrieveImageTask
     {
         setBackgroundImage(placeholderImage, forState: state)
         kf_setBackgroundWebURL(resource.downloadURL, forState: state)