Jelajahi Sumber

Merge branch 'master' into feature/uibutton-support

# Conflicts:
#	Kingfisher/UIImageView+Kingfisher.swift
onevcat 10 tahun lalu
induk
melakukan
fc072792ad

+ 1 - 1
Kingfisher-Demo/ViewController.swift

@@ -57,7 +57,7 @@ extension ViewController: UICollectionViewDataSource {
     
     
     override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
     override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
         let cell = collectionView.dequeueReusableCellWithReuseIdentifier("collectionViewCell", forIndexPath: indexPath) as! CollectionViewCell
         let cell = collectionView.dequeueReusableCellWithReuseIdentifier("collectionViewCell", forIndexPath: indexPath) as! CollectionViewCell
-        cell.cellImageView.kf_setImageWithURL(NSURL(string: "https://raw.githubusercontent.com/onevcat/Kingfisher/master/images/kingfisher-\(indexPath.row + 1).jpg")!, placeHolderImage: nil, options: KingfisherOptions.LowPriority, progressBlock: { (receivedSize, totalSize) -> () in
+        cell.cellImageView.kf_setImageWithURL(NSURL(string: "https://raw.githubusercontent.com/onevcat/Kingfisher/master/images/kingfisher-\(indexPath.row + 1).jpg")!, placeholderImage: nil, options: KingfisherOptions.LowPriority, progressBlock: { (receivedSize, totalSize) -> () in
             println("\(indexPath.row + 1): \(receivedSize)/\(totalSize)")
             println("\(indexPath.row + 1): \(receivedSize)/\(totalSize)")
         }) { (image, error, imageURL) -> () in
         }) { (image, error, imageURL) -> () in
             println("\(indexPath.row + 1): Finished")
             println("\(indexPath.row + 1): Finished")

+ 5 - 5
Kingfisher/ImageCache.swift

@@ -216,7 +216,7 @@ extension ImageCache {
         }
         }
         
         
         let block = dispatch_block_create(DISPATCH_BLOCK_INHERIT_QOS_CLASS) {
         let block = dispatch_block_create(DISPATCH_BLOCK_INHERIT_QOS_CLASS) {
-            if let image = self.retriveImageInMemoryCaheForKey(key) {
+            if let image = self.retrieveImageInMemoryCacheForKey(key) {
                 
                 
                 //Found image in memory cache.
                 //Found image in memory cache.
                 if options.shouldDecode {
                 if options.shouldDecode {
@@ -234,7 +234,7 @@ extension ImageCache {
                 //Begin to load image from disk
                 //Begin to load image from disk
                 dispatch_async(self.ioQueue, { () -> Void in
                 dispatch_async(self.ioQueue, { () -> Void in
                     
                     
-                    if let image = self.retriveImageInDiskCacheForKey(key) {
+                    if let image = self.retrieveImageInDiskCacheForKey(key) {
                         
                         
                         if options.shouldDecode {
                         if options.shouldDecode {
                             dispatch_async(self.processQueue, { () -> Void in
                             dispatch_async(self.processQueue, { () -> Void in
@@ -277,7 +277,7 @@ extension ImageCache {
     
     
     :returns: The image object if it is cached, or `nil` if there is no such key in the cache.
     :returns: The image object if it is cached, or `nil` if there is no such key in the cache.
     */
     */
-    public func retriveImageInMemoryCaheForKey(key: String) -> UIImage? {
+    public func retrieveImageInMemoryCacheForKey(key: String) -> UIImage? {
         return memoryCache.objectForKey(key) as? UIImage
         return memoryCache.objectForKey(key) as? UIImage
     }
     }
     
     
@@ -288,7 +288,7 @@ extension ImageCache {
     
     
     :returns: The image object if it is cached, or `nil` if there is no such key in the cache.
     :returns: The image object if it is cached, or `nil` if there is no such key in the cache.
     */
     */
-    public func retriveImageInDiskCacheForKey(key: String) -> UIImage? {
+    public func retrieveImageInDiskCacheForKey(key: String) -> UIImage? {
         return diskImageForKey(key)
         return diskImageForKey(key)
     }
     }
 }
 }
@@ -452,7 +452,7 @@ extension ImageCache {
 }
 }
 
 
 
 
-// MARK: - Check cache statue
+// MARK: - Check cache status
 public extension ImageCache {
 public extension ImageCache {
     
     
     /**
     /**

+ 4 - 4
Kingfisher/ImageDownloader.swift

@@ -39,7 +39,7 @@ public class ImageDownloader: NSObject {
     
     
     class ImageFetchLoad {
     class ImageFetchLoad {
         var callbacks = [CallbackPair]()
         var callbacks = [CallbackPair]()
-        var responsData = NSMutableData()
+        var responseData = NSMutableData()
         var shouldDecode = false
         var shouldDecode = false
     }
     }
     
     
@@ -166,9 +166,9 @@ extension ImageDownloader: NSURLSessionDataDelegate {
     public func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData data: NSData) {
     public func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData data: NSData) {
 
 
         if let URL = dataTask.originalRequest.URL, fetchLoad = fetchLoads[URL] {
         if let URL = dataTask.originalRequest.URL, fetchLoad = fetchLoads[URL] {
-            fetchLoad.responsData.appendData(data)
+            fetchLoad.responseData.appendData(data)
             for callbackPair in fetchLoad.callbacks {
             for callbackPair in fetchLoad.callbacks {
-                callbackPair.progressBlock?(receivedSize: Int64(fetchLoad.responsData.length), totalSize: dataTask.response!.expectedContentLength)
+                callbackPair.progressBlock?(receivedSize: Int64(fetchLoad.responseData.length), totalSize: dataTask.response!.expectedContentLength)
             }
             }
         }
         }
     }
     }
@@ -193,7 +193,7 @@ extension ImageDownloader: NSURLSessionDataDelegate {
             dispatch_async(processQueue, { () -> Void in
             dispatch_async(processQueue, { () -> Void in
                 
                 
                 if let fetchLoad = self.fetchLoads[URL] {
                 if let fetchLoad = self.fetchLoads[URL] {
-                    if let image = UIImage(data: fetchLoad.responsData) {
+                    if let image = UIImage(data: fetchLoad.responseData) {
                         if fetchLoad.shouldDecode {
                         if fetchLoad.shouldDecode {
                             self.callbackWithImage(image.kf_decodedImage(), error: nil, imageURL: URL)
                             self.callbackWithImage(image.kf_decodedImage(), error: nil, imageURL: URL)
                         } else {
                         } else {

+ 9 - 9
Kingfisher/KingfisherManager.swift

@@ -32,15 +32,15 @@ import Foundation
 */
 */
 public class RetrieveImageTask {
 public class RetrieveImageTask {
     
     
-    var diskRetriveTask: RetrieveImageDiskTask?
+    var diskRetrieveTask: RetrieveImageDiskTask?
     var downloadTask: RetrieveImageDownloadTask?
     var downloadTask: RetrieveImageDownloadTask?
     
     
     /**
     /**
     Cancel current task. If this task does not begin or already done, do nothing.
     Cancel current task. If this task does not begin or already done, do nothing.
     */
     */
     public func cancel() {
     public func cancel() {
-        if let diskRetriveTask = diskRetriveTask {
-            dispatch_block_cancel(diskRetriveTask)
+        if let diskRetrieveTask = diskRetrieveTask {
+            dispatch_block_cancel(diskRetrieveTask)
         }
         }
         
         
         if let downloadTask = downloadTask {
         if let downloadTask = downloadTask {
@@ -106,17 +106,17 @@ public class KingfisherManager {
     
     
     :returns: A `RetrieveImageTask` task object. You can use this object to cancel the task.
     :returns: A `RetrieveImageTask` task object. You can use this object to cancel the task.
     */
     */
-    public func retriveImageWithURL(URL: NSURL,
+    public func retrieveImageWithURL(URL: NSURL,
                                 options: KingfisherOptions,
                                 options: KingfisherOptions,
                           progressBlock:DownloadProgressBlock?,
                           progressBlock:DownloadProgressBlock?,
                       completionHandler:CompletionHandler?) -> RetrieveImageTask
                       completionHandler:CompletionHandler?) -> RetrieveImageTask
     {
     {
         let task = RetrieveImageTask()
         let task = RetrieveImageTask()
         
         
-        let options = (forceRefresh: options & KingfisherOptions.ForceRefresh != KingfisherOptions.None,
-                        lowPriority: options & KingfisherOptions.LowPriority != KingfisherOptions.None,
-                    cacheMemoryOnly: options & KingfisherOptions.CacheMemoryOnly != KingfisherOptions.None,
-                       shouldDecode: options & KingfisherOptions.BackgroundDecode != KingfisherOptions.None)
+        let options = (forceRefresh: (options & KingfisherOptions.ForceRefresh) != KingfisherOptions.None,
+                        lowPriority: (options & KingfisherOptions.LowPriority) != KingfisherOptions.None,
+                    cacheMemoryOnly: (options & KingfisherOptions.CacheMemoryOnly) != KingfisherOptions.None,
+                       shouldDecode: (options & KingfisherOptions.BackgroundDecode) != KingfisherOptions.None)
 
 
         if let key = URL.absoluteString {
         if let key = URL.absoluteString {
             if options.forceRefresh {
             if options.forceRefresh {
@@ -139,7 +139,7 @@ public class KingfisherManager {
                             options: options)
                             options: options)
                     }
                     }
                 })
                 })
-                task.diskRetriveTask = diskTask
+                task.diskRetrieveTask = diskTask
             }
             }
         }
         }
         
         

+ 18 - 18
Kingfisher/UIImageView+Kingfisher.swift

@@ -1,6 +1,6 @@
 //
 //
 //  UIImageView+Kingfisher.swift
 //  UIImageView+Kingfisher.swift
-//  Kingfisher
+//  WebImageDemo
 //
 //
 //  Created by Wei Wang on 15/4/6.
 //  Created by Wei Wang on 15/4/6.
 //
 //
@@ -42,62 +42,62 @@ public extension UIImageView {
     */
     */
     public func kf_setImageWithURL(URL: NSURL) -> RetrieveImageTask
     public func kf_setImageWithURL(URL: NSURL) -> RetrieveImageTask
     {
     {
-        return kf_setImageWithURL(URL, placeHolderImage: nil, options: KingfisherOptions.None, progressBlock: nil, completionHandler: nil)
+        return kf_setImageWithURL(URL, placeholderImage: nil, options: KingfisherOptions.None, progressBlock: nil, completionHandler: nil)
     }
     }
     
     
     /**
     /**
     Set an image with a URL and a place holder image.
     Set an image with a URL and a place holder image.
     
     
     :param: URL              The URL of image.
     :param: URL              The URL of image.
-    :param: placeHolderImage A placeholder image when retrieving the image at URL.
+    :param: placeholderImage A placeholder image when retrieving the image at URL.
     
     
     :returns: A task represents the retriving process.
     :returns: A task represents the retriving process.
     */
     */
     public func kf_setImageWithURL(URL: NSURL,
     public func kf_setImageWithURL(URL: NSURL,
-                      placeHolderImage: UIImage?) -> RetrieveImageTask
+                      placeholderImage: UIImage?) -> RetrieveImageTask
     {
     {
-        return kf_setImageWithURL(URL, placeHolderImage: placeHolderImage, options: KingfisherOptions.None, progressBlock: nil, completionHandler: nil)
+        return kf_setImageWithURL(URL, placeholderImage: placeholderImage, options: KingfisherOptions.None, progressBlock: nil, completionHandler: nil)
     }
     }
     
     
     /**
     /**
     Set an image with a URL, a place holder image and options.
     Set an image with a URL, a place holder image and options.
     
     
     :param: URL              The URL of image.
     :param: URL              The URL of image.
-    :param: placeHolderImage A placeholder image when retrieving the image at URL.
+    :param: placeholderImage A placeholder image when retrieving the image at URL.
     :param: options          Options which could control some behaviors. See `KingfisherOptions` for more.
     :param: options          Options which could control some behaviors. See `KingfisherOptions` for more.
     
     
     :returns: A task represents the retriving process.
     :returns: A task represents the retriving process.
     */
     */
     public func kf_setImageWithURL(URL: NSURL,
     public func kf_setImageWithURL(URL: NSURL,
-                      placeHolderImage: UIImage?,
+                      placeholderImage: UIImage?,
                                options: KingfisherOptions) -> RetrieveImageTask
                                options: KingfisherOptions) -> RetrieveImageTask
     {
     {
-        return kf_setImageWithURL(URL, placeHolderImage: placeHolderImage, options: options, progressBlock: nil, completionHandler: nil)
+        return kf_setImageWithURL(URL, placeholderImage: placeholderImage, options: options, progressBlock: nil, completionHandler: nil)
     }
     }
     
     
     /**
     /**
     Set an image with a URL, a place holder image, options and completion handler.
     Set an image with a URL, a place holder image, options and completion handler.
     
     
     :param: URL               The URL of image.
     :param: URL               The URL of image.
-    :param: placeHolderImage  A placeholder image when retrieving the image at URL.
+    :param: placeholderImage  A placeholder image when retrieving the image at URL.
     :param: options           Options which could control some behaviors. See `KingfisherOptions` for more.
     :param: options           Options which could control some behaviors. See `KingfisherOptions` for more.
     :param: completionHandler Called when the image retrieved and set.
     :param: completionHandler Called when the image retrieved and set.
     
     
     :returns: A task represents the retriving process.
     :returns: A task represents the retriving process.
     */
     */
     public func kf_setImageWithURL(URL: NSURL,
     public func kf_setImageWithURL(URL: NSURL,
-                      placeHolderImage: UIImage?,
+                      placeholderImage: UIImage?,
                                options: KingfisherOptions,
                                options: KingfisherOptions,
                      completionHandler: CompletionHandler?) -> RetrieveImageTask
                      completionHandler: CompletionHandler?) -> RetrieveImageTask
     {
     {
-        return kf_setImageWithURL(URL, placeHolderImage: placeHolderImage, options: options, progressBlock: nil, completionHandler: completionHandler)
+        return kf_setImageWithURL(URL, placeholderImage: placeholderImage, options: options, progressBlock: nil, completionHandler: completionHandler)
     }
     }
     
     
     /**
     /**
     Set an image with a URL, a place holder image, options, progress handler and completion handler.
     Set an image with a URL, a place holder image, options, progress handler and completion handler.
     
     
     :param: URL               The URL of image.
     :param: URL               The URL of image.
-    :param: placeHolderImage  A placeholder image when retrieving the image at URL.
+    :param: placeholderImage  A placeholder image when retrieving the image at URL.
     :param: options           Options which could control some behaviors. See `KingfisherOptions` for more.
     :param: options           Options which could control some behaviors. See `KingfisherOptions` for more.
     :param: progressBlock     Called when the image downloading progress gets updated.
     :param: progressBlock     Called when the image downloading progress gets updated.
     :param: completionHandler Called when the image retrieved and set.
     :param: completionHandler Called when the image retrieved and set.
@@ -105,15 +105,15 @@ public extension UIImageView {
     :returns: A task represents the retriving process.
     :returns: A task represents the retriving process.
     */
     */
     public func kf_setImageWithURL(URL: NSURL,
     public func kf_setImageWithURL(URL: NSURL,
-                      placeHolderImage: UIImage?,
+                      placeholderImage: UIImage?,
                                options: KingfisherOptions,
                                options: KingfisherOptions,
                          progressBlock: DownloadProgressBlock?,
                          progressBlock: DownloadProgressBlock?,
                      completionHandler: CompletionHandler?) -> RetrieveImageTask
                      completionHandler: CompletionHandler?) -> RetrieveImageTask
     {
     {
-        image = placeHolderImage
+        image = placeholderImage
         
         
         self.kf_setWebURL(URL)
         self.kf_setWebURL(URL)
-        let task = KingfisherManager.sharedManager.retriveImageWithURL(URL, options: options, progressBlock: { (receivedSize, totalSize) -> () in
+        let task = KingfisherManager.sharedManager.retrieveImageWithURL(URL, options: options, progressBlock: { (receivedSize, totalSize) -> () in
             if let progressBlock = progressBlock {
             if let progressBlock = progressBlock {
                 dispatch_async(dispatch_get_main_queue(), { () -> Void in
                 dispatch_async(dispatch_get_main_queue(), { () -> Void in
                     progressBlock(receivedSize: receivedSize, totalSize: totalSize)
                     progressBlock(receivedSize: receivedSize, totalSize: totalSize)
@@ -133,16 +133,16 @@ public extension UIImageView {
 }
 }
 
 
 // MARK: - Associated Object
 // MARK: - Associated Object
-private var lastURLKey: Void?
+private var lastURLkey: Void?
 public extension UIImageView {
 public extension UIImageView {
     /// Get the image URL binded to this image view. You can use `kf_setImage` methods to set it.
     /// Get the image URL binded to this image view. You can use `kf_setImage` methods to set it.
     public var kf_webURL: NSURL? {
     public var kf_webURL: NSURL? {
         get {
         get {
-            return objc_getAssociatedObject(self, &lastURLKey) as? NSURL
+            return objc_getAssociatedObject(self, &lastURLkey) as? NSURL
         }
         }
     }
     }
     
     
     private func kf_setWebURL(URL: NSURL) {
     private func kf_setWebURL(URL: NSURL) {
-        objc_setAssociatedObject(self, &lastURLKey, URL, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
+        objc_setAssociatedObject(self, &lastURLkey, URL, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
     }
     }
 }
 }

+ 3 - 3
README.md

@@ -137,7 +137,7 @@ imageView.kf_setImageWithURL(NSURL(string: "http://your_image_url.png")!)
 Most cases, Kingfisher is used in a reusable cell. Since the downloading process is asynchronous, the earlier image will be remained during the downloading of newer one. The placeholder version of this API could help:
 Most cases, Kingfisher is used in a reusable cell. Since the downloading process is asynchronous, the earlier image will be remained during the downloading of newer one. The placeholder version of this API could help:
 
 
 ```swift
 ```swift
-imageView.kf_setImageWithURL(NSURL(string: "http://your_image_url.png")!, placeHolderImage: nil)
+imageView.kf_setImageWithURL(NSURL(string: "http://your_image_url.png")!, placeholderImage: nil)
 ```
 ```
 
 
 #### Options
 #### Options
@@ -146,7 +146,7 @@ Kingfisher will search in cache (both memory and disk) first with the URL, if no
 
 
 ```swift
 ```swift
 imageView.kf_setImageWithURL(NSURL(string: "your_image_url")!, 
 imageView.kf_setImageWithURL(NSURL(string: "your_image_url")!, 
-                         placeHolderImage: nil, 
+                         placeholderImage: nil, 
                                   options: KingfisherOptions.ForceRefresh)
                                   options: KingfisherOptions.ForceRefresh)
 ```
 ```
 
 
@@ -158,7 +158,7 @@ You can get a chance during Kingfisher downloads images and when the process don
 
 
 ```swift
 ```swift
 imageView.kf_setImageWithURL(NSURL(string: "your_image_url")!,
 imageView.kf_setImageWithURL(NSURL(string: "your_image_url")!,
-                         placeHolderImage: nil,
+                         placeholderImage: nil,
                                   options: KingfisherOptions.None,
                                   options: KingfisherOptions.None,
                             progressBlock: { (receivedSize, totalSize) -> () in
                             progressBlock: { (receivedSize, totalSize) -> () in
                                 println("Download Progress: \(receivedSize)/\(totalSize)")
                                 println("Download Progress: \(receivedSize)/\(totalSize)")