Browse Source

Ensure code compiles on Swift 4.1 and earlier without warnings

Sebastian Hagedorn 7 years ago
parent
commit
0a5fcb81fc
1 changed files with 5 additions and 1 deletions
  1. 5 1
      Lib/KeychainAccess/Keychain.swift

+ 5 - 1
Lib/KeychainAccess/Keychain.swift

@@ -778,7 +778,11 @@ public final class Keychain {
     }
     }
 
 
     public func allKeys() -> [String] {
     public func allKeys() -> [String] {
-        return type(of: self).prettify(itemClass: itemClass, items: items()).compactMap { $0["key"] as? String }
+        #if swift(>=4.1)
+            return type(of: self).prettify(itemClass: itemClass, items: items()).compactMap { $0["key"] as? String }
+        #else
+            return type(of: self).prettify(itemClass: itemClass, items: items()).flatMap { $0["key"] as? String }
+        #endif
     }
     }
 
 
     public class func allItems(_ itemClass: ItemClass) -> [[String: Any]] {
     public class func allItems(_ itemClass: ItemClass) -> [[String: Any]] {