Skip to content
This repository was archived by the owner on Aug 26, 2022. It is now read-only.

Commit ffbac3f

Browse files
authored
Fixes #23 Remove Hashable constraint for ID (#30)
1 parent 6a6dd19 commit ffbac3f

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

README_TR.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible" /></a>
1212
<a href="https://swift.org/package-manager/"><img src="https://img.shields.io/badge/SPM-compatible-4BC51D.svg?style=flat" alt="Swift Package Manager compatible" /></a>
1313
<a href="https://swift.org"><img src="https://img.shields.io/badge/Swift-4.2-orange.svg" alt="Swift" /></a>
14-
<a href="https://developer.apple.com/xcode"><img src="https://img.shields.io/badge/Xcode-9.4-blue.svg" alt="Xcode"></a>
14+
<a href="https://developer.apple.com/xcode"><img src="https://img.shields.io/badge/Xcode-10-blue.svg" alt="Xcode"></a>
1515
<a href="https://github.com/omaralbeik/UserDefaultsStore/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-red.svg" alt="MIT"></a>
1616
</p>
1717

1818

1919
# tl;dr
2020

21-
Swift'in `Codable` protokolüne bayılıyorsun ve her yerde kullanıyorsun, kim kullanmadı ki! İşte `Codable` objelerini saklamak ve istediğiniz zaman geri almak için kolay ve hafif bir yol!
21+
Swift'in `Codable` protokolüne bayılıyorsun ve her yerde kullanıyorsun, kim kullanmadı ki! İşte `Codable` objelerini saklamak ve istediğiniz zaman geri almak için kolay ve hafif bir yol!
2222

2323

2424
## Kurulum
@@ -150,14 +150,14 @@ let usersCount = usersStore.objectsCount
150150
```
151151

152152

153-
##
153+
##
154154
[`SingleUserDefaultsStore`](https://github.com/omaralbeik/UserDefaultsStore/blob/master/Sources/SingleUserDefaultsStore.swift)'ı kullanarak tek bir nesneyi saklayabilirsiniz. Token ve giriş yapmış kullanıcı verisi gibi, ...
155155

156156

157157
## Gereksinimler
158158
- iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+
159-
- Xcode 9+
160-
- Swift 4+
159+
- Xcode 10.0+
160+
- Swift 4.2+
161161

162162

163163
## Teşekkürler
@@ -170,5 +170,3 @@ Swift Keypath'leri kullanarak daha doğal kod nasıl yazılır sorusuna cevap ve
170170

171171
## Lisans
172172
UserDefaultsStore MIT lisansı altında yayınlandı. Daha fazlası için [LICENSE](https://github.com/omaralbeik/UserDefaultsStore/blob/master/LICENSE) dosyasına bakabilirsiniz.
173-
174-

Sources/Identifiable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Foundation
2727
public protocol Identifiable {
2828

2929
/// ID type.
30-
associatedtype ID: Hashable
30+
associatedtype ID
3131

3232
/// Id Key.
3333
static var idKey: WritableKeyPath<Self, ID> { get }

Sources/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.2.2</string>
18+
<string>1.3</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

Sources/SingleUserDefaultsStore.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ open class SingleUserDefaultsStore<T: Codable> {
6969

7070
/// Delete object from store. _O(1)_
7171
public func delete() {
72+
store.set(nil, forKey: key)
7273
store.removeSuite(named: uniqueIdentifier)
7374
}
7475

Sources/UserDefaultsStore.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ private extension UserDefaultsStore {
186186
/// - Parameter object: object.
187187
/// - Returns: UserDefaults key for given object.
188188
func key(for object: T) -> String {
189-
return "\(uniqueIdentifier)-\(object[keyPath: T.idKey].hashValue)"
189+
return "\(uniqueIdentifier)-\(object[keyPath: T.idKey])"
190190
}
191191

192192
/// store key for object by its id.
193193
///
194194
/// - Parameter id: object id.
195195
/// - Returns: UserDefaults key for given id.
196196
func key(for id: T.ID) -> String {
197-
return "\(uniqueIdentifier)-\(id.hashValue)"
197+
return "\(uniqueIdentifier)-\(id)"
198198
}
199199

200200
/// Check if a UserDefaults key is an object key.

UserDefaultsStore.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "UserDefaultsStore"
3-
s.version = "1.2.2"
3+
s.version = "1.3"
44
s.summary = "Why not use UserDefaults to store Codable objects 😉"
55
s.description = <<-DESC
66
You love Swift"s Codable protocol and use it everywhere, here is an easy and very light way to store - reasonable amount 😅 - of Codable objects, in a couple lines of code.

0 commit comments

Comments
 (0)