Skip to content

Commit 92bc71f

Browse files
committed
Fix lint errors
1 parent 796d018 commit 92bc71f

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

Sources/FHPropertyWrappers/SecureStored/SecureStorable+SupportedTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extension String: SecureStorable {
2828
public static func read(key: SecureStoreKey, accessibility: SecureStoreAccessibility) throws -> String? {
2929
let query = _keychainQuery(key: key, accessibility: accessibility)
3030
guard let data = try _keychainGet(query: query) else { return nil }
31-
return String(decoding: data, as: UTF8.self)
31+
return String(bytes: data, encoding: .utf8)
3232
}
3333

3434
public static func write(value: String, for key: SecureStoreKey, accessibility: SecureStoreAccessibility) throws {

Sources/FHPropertyWrappers/Stored/Storable+SupportedTypes.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ extension Array: Storable where Element: RawStorable {
119119
return []
120120
}
121121

122-
public static func read(in store: UserDefaults, key: StoreKey) throws -> Array? {
123-
return store.value(forKey: key._value) as? Array
122+
public static func read(in store: UserDefaults, key: StoreKey) throws -> Self? {
123+
return store.value(forKey: key._value) as? Self
124124
}
125125

126126
public static func write(value: Array, in store: UserDefaults, key: StoreKey) throws {
@@ -133,8 +133,8 @@ extension Dictionary: Storable where Key: RawStorable, Value: RawStorable {
133133
return [:]
134134
}
135135

136-
public static func read(in store: UserDefaults, key: StoreKey) throws -> Dictionary? {
137-
return store.value(forKey: key._value) as? Dictionary
136+
public static func read(in store: UserDefaults, key: StoreKey) throws -> Self? {
137+
return store.value(forKey: key._value) as? Self
138138
}
139139

140140
public static func write(value: Dictionary, in store: UserDefaults, key: StoreKey) throws {

Tests/FHPropertyWrappersTests/SecureStoredTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ final class SecureStoredTests: XCTestCase { // swiftlint:disable:this type_body_
260260
string = "string"
261261
XCTAssertEqual(string, "string")
262262
let data = try XCTUnwrap(_getData(key: $string.key))
263-
XCTAssertEqual(String(decoding: data, as: UTF8.self), "string")
263+
XCTAssertEqual(String(bytes: data, encoding: .utf8), "string")
264264

265265
$string.remove()
266266
XCTAssertEqual(string, "")
@@ -347,7 +347,7 @@ final class SecureStoredTests: XCTestCase { // swiftlint:disable:this type_body_
347347
optional = "test"
348348
XCTAssertEqual(optional, "test")
349349
let data = _getData(key: $optional.key)
350-
let string = data.map { String(decoding: $0, as: UTF8.self) }
350+
let string = data.flatMap { String(bytes: $0, encoding: .utf8) }
351351
XCTAssertEqual(string, "test")
352352

353353
optional = nil
@@ -379,7 +379,7 @@ final class SecureStoredTests: XCTestCase { // swiftlint:disable:this type_body_
379379
rawRepresentable = .b
380380
XCTAssertEqual(rawRepresentable, .b)
381381
let data = try XCTUnwrap(_getData(key: $rawRepresentable.key))
382-
XCTAssertEqual(String(decoding: data, as: UTF8.self), "b")
382+
XCTAssertEqual(String(bytes: data, encoding: .utf8), "b")
383383

384384
$rawRepresentable.remove()
385385
XCTAssertEqual(rawRepresentable, .a)

0 commit comments

Comments
 (0)