Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sgxiang/YTKKeyValueStore_Swift
A simple Key-Value storage tool, using Sqlite as backend.
https://github.com/sgxiang/YTKKeyValueStore_Swift
Last synced: 3 months ago
JSON representation
A simple Key-Value storage tool, using Sqlite as backend.
- Host: GitHub
- URL: https://github.com/sgxiang/YTKKeyValueStore_Swift
- Owner: sgxiang
- License: mit
- Created: 2014-12-08T03:58:45.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-06-12T13:34:33.000Z (over 5 years ago)
- Last Synced: 2024-04-26T17:08:17.987Z (7 months ago)
- Language: Swift
- Homepage:
- Size: 648 KB
- Stars: 194
- Watchers: 10
- Forks: 30
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
YTKKeyValueStore
==========[![CocoaPods Version](https://cocoapod-badges.herokuapp.com/v/YTKKeyValueStore_Swift/badge.png)](http://cocoadocs.org/docsets/YTKKeyValueStore_Swift) [![Platform](https://cocoapod-badges.herokuapp.com/p/YTKKeyValueStore_Swift/badge.png)](http://cocoadocs.org/docsets/YTKKeyValueStore_Swift) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![License MIT](https://go-shields.herokuapp.com/license-MIT-blue.png)
objc version :https://github.com/yuantiku/YTKKeyValueStore
## Requirements
- iOS 9.0+
- Xcode 8.0
- Swift 3.0## Usage
```swift
import YTKKeyValueStore
```### YTKKeyValueStore
```swift
var store = try! YTKKeyValueStore("dbtest.sqlite3") // create or open the key-value storetry! store.createTable(tableName: "User") // create table
let table = store["User"] // get table (YTKTable)
try! store.dropTable("User") // drop table
```### YTKTable
```swift
let isExists = table.isExiststry! table.put( "name" <- "sgxiang") // put value("sgxiang") for key("name") into table , support string,number,dictionary,array
let objct = try! table.get("name") // get object with key , return YTKObject?
let item = try! table.getItem("name") // get item with key ,return YTKItem?
let allItems = try! table.getAllItems() // get all item with key , return [YTKItem]?try! table.clear() // clear table
try! table.delete("name1","name2") // delete row where key == "name1" and "name2"
try! table.deletePreLike("name") // delete row where key pre like "name"
```### YTKItem
```
itemId : itemKey
itemObject : itemValue , is json string
createdTime : item created time
```
### YTKObject```
objectValue : return AnyObject?
stringValue : return String?
numberValue : return NSNumber?
dictionaryValue : return Dictionary?
arrayValue : return Array?
```## Installation
### Carthage
Update Cartfile to include the following:
```
github "sgxiang/YTKKeyValueStore_Swift" ~> 0.4.2
```Run `carthage update` and [add the appropriate framework][Carthage Usage].
[Carthage Usage]: https://github.com/Carthage/Carthage#adding-frameworks-to-an-application
### CocoaPods
Update Podfile to include the following:
```ruby
use_frameworks!pod 'YTKKeyValueStore_Swift', '~> 0.4.2'
```Run `pod install`
### Embedded Framework
- Add YTKKeyValueStore as a submodule by opening the Terminal, cd-ing into your top-level project directory, and entering the following command:
```
$ git submodule add https://github.com/Sgxiang/YTKKeyValueStore_Swift.git
```
- Open the YTKKeyValueStore folder, and drag YTKKeyValueStore.xcodeproj into the file navigator of your app project.- In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
- Ensure that the deployment target of YTKKeyValueStore.framework matches that of the application target.
- In the tab bar at the top of that window, open the "Build Phases" panel.
Expand the "Target Dependencies" group, and add YTKKeyValueStore.framework.- Click on the + button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add YTKKeyValueStore.framework.
## Communication
- Found a bug or have a feature request? [Open an issue](https://github.com/sgxiang/YTKKeyValueStore_Swift/issues).
- Want to contribute? [Submit a pull request](https://github.com/sgxiang/YTKKeyValueStore_Swift/pulls).
## Author
- [sgxiang](https://twitter.com/sgxiang1992)