swiftkitz / storez Goto Github PK
View Code? Open in Web Editor NEW๐พ Safe, statically-typed, store-agnostic key-value storage written in Swift!
Home Page: https://swiftkitz.github.io/
License: MIT License
๐พ Safe, statically-typed, store-agnostic key-value storage written in Swift!
Home Page: https://swiftkitz.github.io/
License: MIT License
Add user defaults migration helper, which takes a list of of MigrationInfo
. MigrationInfo
is a struct that contains a KeyType
to be migrated to, String
which is the old key, and a processing block, that takes the old value and processes it to to return a new suitable value for KeyType
.
This is the actual use case that I have. I have simplified it so it makes more sense:
old value: "CityId" -> "kw-city-asimah"
new key: "general-settings:city" -> ""
so, we can do this:
let migrationInfo = MigrationInfo(
keyType = Key<GeneralSettings, City>(id: "city", defaultValue: City.asimah),
oldKey = "CityId",
processor = { oldValue in
// process from a string to a City type
return mydb.getCity(oldValue)
})
I try to create some custom objects,
struct StorezArray {
var arrStr: [String]
}
extension StorezArray: UserDefaultsConvertible {
typealias UserDefaultsType = String
var encodeForUserDefaults: StorezArray.UserDefaultsType? {
return arrStr.joined(separator: ";")
}
static func decode(userDefaultsValue value: StorezArray.UserDefaultsType) -> StorezArray? {
return self.init(arrStr: value.components(separatedBy: ";"))
}
}
but xcode always says
Type 'StorezArray' does not conform to protocol 'UserDefaultsConvertible'
even though i add the protocol stub
Hi there!
How can I get all items stored under a certain Namespace? For example, I have the following namespace:
struct ListsNamespace: Namespace {
static let id = "lists"
}
and I want to fetch all 'List' items.
Thanks!
Probably makes sense to support Cocoapods using subspecs, so users can perhaps add support to Realm, SQLite, CoreData ... etc, without affecting light-weight stores.
As simple as adding a tag with the Carthage support badge. Well, the readme should probably be updated as well.
The following code passes the first time. When the test is run a second time it fails.
func testUserDefaultsBuggyClear() {
var testStore = UserDefaultsStore(suite: "io.kitz.storez.test")
let key = Key<GlobalNamespace, Int?>(id: "foo", defaultValue: nil)
testStore.clear()
XCTAssertNil(testStore.get(key))
testStore.set(key, value: 666)
XCTAssertEqual(testStore.get(key), 666)
testStore.clear()
XCTAssertNil(testStore.get(key))
testStore = UserDefaultsStore(suite: "io.kitz.storez.test")
XCTAssertNil(testStore.get(key))
testStore.set(key, value: 666)
}
Run the following code several times and it eventually will always pass:
func testUserDefaultsClear() {
var testStore = UserDefaultsStore(suite: "io.kitz.storez.test")
let key = Key<GlobalNamespace, Int?>(id: "foo", defaultValue: nil)
testStore.clear()
XCTAssertNil(testStore.get(key))
testStore.set(key, value: 666)
XCTAssertEqual(testStore.get(key), 666)
testStore.clear()
XCTAssertNil(testStore.get(key))
testStore = UserDefaultsStore(suite: "io.kitz.storez.test")
XCTAssertNil(testStore.get(key))
testStore.set(key, value: 666)
testStore.clear()
}
build failed in carthage and when i build in Xcode i get the incurrent headers.
the season is like this:
The following build commands failed:
Check dependencies
(1 failure)
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
warning: no umbrella header found for target 'Storez-ios', module map will not be generated
warning: no umbrella header found for target 'Storez-ios', module map will not be generated
A shell task (/usr/bin/xcrun xcodebuild -workspace /Carthage/Checkouts/Storez/Storez.xcworkspace -scheme Storez-ios -configuration Release -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build) failed with exit code 65:/Carthage/Checkouts/Storez/Playground/Playground.playground' in workspace '~/Carthage/Checkouts/Storez/Storez.xcworkspace'.
--- xcodebuild: WARNING: Unable to open project file '
** CLEAN FAILED **
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.