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

Commit

Permalink
Fixes #23 Remove Hashable constraint for ID (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
omaralbeik authored Oct 4, 2018
1 parent 6a6dd19 commit ffbac3f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
12 changes: 5 additions & 7 deletions README_TR.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible" /></a>
<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>
<a href="https://swift.org"><img src="https://img.shields.io/badge/Swift-4.2-orange.svg" alt="Swift" /></a>
<a href="https://developer.apple.com/xcode"><img src="https://img.shields.io/badge/Xcode-9.4-blue.svg" alt="Xcode"></a>
<a href="https://developer.apple.com/xcode"><img src="https://img.shields.io/badge/Xcode-10-blue.svg" alt="Xcode"></a>
<a href="https://github.com/omaralbeik/UserDefaultsStore/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-red.svg" alt="MIT"></a>
</p>


# tl;dr

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!
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!


## Kurulum
Expand Down Expand Up @@ -150,14 +150,14 @@ let usersCount = usersStore.objectsCount
```


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


## Gereksinimler
- iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+
- Xcode 9+
- Swift 4+
- Xcode 10.0+
- Swift 4.2+


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

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


2 changes: 1 addition & 1 deletion Sources/Identifiable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Foundation
public protocol Identifiable {

/// ID type.
associatedtype ID: Hashable
associatedtype ID

/// Id Key.
static var idKey: WritableKeyPath<Self, ID> { get }
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.2.2</string>
<string>1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
1 change: 1 addition & 0 deletions Sources/SingleUserDefaultsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ open class SingleUserDefaultsStore<T: Codable> {

/// Delete object from store. _O(1)_
public func delete() {
store.set(nil, forKey: key)
store.removeSuite(named: uniqueIdentifier)
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/UserDefaultsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ private extension UserDefaultsStore {
/// - Parameter object: object.
/// - Returns: UserDefaults key for given object.
func key(for object: T) -> String {
return "\(uniqueIdentifier)-\(object[keyPath: T.idKey].hashValue)"
return "\(uniqueIdentifier)-\(object[keyPath: T.idKey])"
}

/// store key for object by its id.
///
/// - Parameter id: object id.
/// - Returns: UserDefaults key for given id.
func key(for id: T.ID) -> String {
return "\(uniqueIdentifier)-\(id.hashValue)"
return "\(uniqueIdentifier)-\(id)"
}

/// Check if a UserDefaults key is an object key.
Expand Down
2 changes: 1 addition & 1 deletion UserDefaultsStore.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "UserDefaultsStore"
s.version = "1.2.2"
s.version = "1.3"
s.summary = "Why not use UserDefaults to store Codable objects 😉"
s.description = <<-DESC
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.
Expand Down

0 comments on commit ffbac3f

Please sign in to comment.