Răsfoiți Sursa

Fix the some statements with Xcode 8.0 beta 2

tokorom 9 ani în urmă
părinte
comite
3b8f19f8e1

+ 3 - 3
Sources/AnimatedImageView.swift

@@ -67,8 +67,8 @@ public class AnimatedImageView: UIImageView {
                 return
             } else {
                 stopAnimating()
-                displayLink.remove(from: RunLoop.main(), forMode: runLoopMode.rawValue)
-                displayLink.add(to: RunLoop.main(), forMode: newValue.rawValue)
+                displayLink.remove(from: RunLoop.main, forMode: runLoopMode)
+                displayLink.add(to: RunLoop.main, forMode: newValue)
                 startAnimating()
             }
         }
@@ -85,7 +85,7 @@ public class AnimatedImageView: UIImageView {
     private lazy var displayLink: CADisplayLink = {
         self.displayLinkInitialized = true
         let displayLink = CADisplayLink(target: TargetProxy(target: self), selector: #selector(TargetProxy.onScreenUpdate))
-        displayLink.add(to: RunLoop.main(), forMode: self.runLoopMode.rawValue)
+        displayLink.add(to: RunLoop.main, forMode: self.runLoopMode)
         displayLink.isPaused = true
         return displayLink
     }()

+ 5 - 5
Sources/ImageCache.swift

@@ -130,14 +130,14 @@ public class ImageCache {
         })
         
 #if !os(OSX) && !os(watchOS)
-        NotificationCenter.default().addObserver(self, selector: #selector(ImageCache.clearMemoryCache), name: NSNotification.Name.UIApplicationDidReceiveMemoryWarning, object: nil)
-        NotificationCenter.default().addObserver(self, selector: #selector(ImageCache.cleanExpiredDiskCache), name: NSNotification.Name.UIApplicationWillTerminate, object: nil)
-        NotificationCenter.default().addObserver(self, selector: #selector(ImageCache.backgroundCleanExpiredDiskCache), name: NSNotification.Name.UIApplicationDidEnterBackground, object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(ImageCache.clearMemoryCache), name: NSNotification.Name.UIApplicationDidReceiveMemoryWarning, object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(ImageCache.cleanExpiredDiskCache), name: NSNotification.Name.UIApplicationWillTerminate, object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(ImageCache.backgroundCleanExpiredDiskCache), name: NSNotification.Name.UIApplicationDidEnterBackground, object: nil)
 #endif
     }
     
     deinit {
-        NotificationCenter.default().removeObserver(self)
+        NotificationCenter.default.removeObserver(self)
     }
 }
 
@@ -425,7 +425,7 @@ extension ImageCache {
                         return url.lastPathComponent!
                     })
                     
-                    NotificationCenter.default().post(name: Notification.Name(rawValue: KingfisherDidCleanDiskCacheNotification), object: self, userInfo: [KingfisherDiskCacheCleanedHashKey: cleanedHashes])
+                    NotificationCenter.default.post(name: Notification.Name(rawValue: KingfisherDidCleanDiskCacheNotification), object: self, userInfo: [KingfisherDiskCacheCleanedHashKey: cleanedHashes])
                 }
                 
                 completionHandler?()

+ 3 - 3
Sources/ImageDownloader.swift

@@ -156,9 +156,9 @@ public class ImageDownloader: NSObject {
     public var trustedHosts: Set<String>?
     
     /// Use this to set supply a configuration for the downloader. By default, NSURLSessionConfiguration.ephemeralSessionConfiguration() will be used. You could change the configuration before a downloaing task starts. A configuration without persistent storage for caches is requsted for downloader working correctly.
-    public var sessionConfiguration = URLSessionConfiguration.ephemeral() {
+    public var sessionConfiguration = URLSessionConfiguration.ephemeral {
         didSet {
-            session = URLSession(configuration: sessionConfiguration, delegate: sessionHandler, delegateQueue: OperationQueue.main())
+            session = URLSession(configuration: sessionConfiguration, delegate: sessionHandler, delegateQueue: OperationQueue.main)
         }
     }
     
@@ -211,7 +211,7 @@ public class ImageDownloader: NSObject {
         // Provide a default implement for challenge responder.
         authenticationChallengeResponder = sessionHandler
         
-        session = URLSession(configuration: sessionConfiguration, delegate: sessionHandler, delegateQueue: OperationQueue.main())
+        session = URLSession(configuration: sessionConfiguration, delegate: sessionHandler, delegateQueue: OperationQueue.main)
     }
     
     func fetchLoadForKey(_ key: URL) -> ImageFetchLoad? {

+ 1 - 1
Sources/ThreadHelper.swift

@@ -34,7 +34,7 @@ func dispatch_async_safely_to_main_queue(_ block: ()->()) {
 // If the `queue` is the main queue, and current thread is main thread, the block 
 // will be invoked immediately instead of being dispatched.
 func dispatch_async_safely_to_queue(_ queue: DispatchQueue, _ block: ()->()) {
-    if queue === DispatchQueue.main && Thread.isMainThread() {
+    if queue === DispatchQueue.main && Thread.isMainThread {
         block()
     } else {
         queue.async {