omaralbeik / UserDefaultsStore

Why not use UserDefaults to store Codable objects 😉

Home Page:https://omaralbeik.github.io/UserDefaultsStore/documentation/userdefaultsstore/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use hash value as key?

ddddxxx opened this issue · comments

Looks dangerous.

Hash values are not guaranteed to be equal across different executions of your program. Do not save hash values to use during a future execution.

Yeah, there is no perfect hashing function, although for the scope of this project I think it is ok to just use the hash values. Please note that this library is not a database solution in any way, this is like a tiny caching layer for your projects.

@ddddxxx Any suggestion to improve this is highly appreicated 😃

Since Xcode 10, this library is no longer usable: https://github.com/apple/swift-evolution/blob/master/proposals/0206-hashable-enhancements.md
Even with Swift 4, because Xcode 10 comes with Swift 4.2 and has compatibility mode for Swift 4.

This issue should be reopened.

Thanks for bringing this up again @fcapon :)
I removed the Hashable constraint in #30

Thanks! 🤗