├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── YTKKeyValueStore.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── YTKKeyValueStore.xcscmblueprint └── xcshareddata │ └── xcschemes │ └── YTKKeyValueStore.xcscheme ├── YTKKeyValueStore ├── Info.plist ├── YTKConfig.swift ├── YTKError.swift ├── YTKItem.swift ├── YTKKeyValueStore.h ├── YTKKeyValueStore.swift ├── YTKObject.swift ├── YTKSetter.swift └── YTKTable.swift ├── YTKKeyValueStoreTests ├── Info.plist └── YTKKeyValueStoreTests.swift └── YTKKeyValueStore_Swift.podspec /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | 28 | # Carthage 29 | Carthage 30 | 31 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Vendor/SQLite.swift"] 2 | path = Vendor/SQLite.swift 3 | url = https://github.com/stephencelis/SQLite.swift.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2014 YTKKeyValueStore_Swift https://github.com/sgxiang 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | YTKKeyValueStore 2 | ========== 3 | 4 | [![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) 5 | 6 | objc version :https://github.com/yuantiku/YTKKeyValueStore 7 | 8 | 9 | 10 | ## Requirements 11 | 12 | - iOS 9.0+ 13 | - Xcode 8.0 14 | - Swift 3.0 15 | 16 | ## Usage 17 | 18 | ```swift 19 | import YTKKeyValueStore 20 | ``` 21 | 22 | ### YTKKeyValueStore 23 | 24 | ```swift 25 | var store = try! YTKKeyValueStore("dbtest.sqlite3") // create or open the key-value store 26 | 27 | try! store.createTable(tableName: "User") // create table 28 | 29 | let table = store["User"] // get table (YTKTable) 30 | 31 | try! store.dropTable("User") // drop table 32 | ``` 33 | 34 | ### YTKTable 35 | 36 | ```swift 37 | let isExists = table.isExists 38 | 39 | try! table.put( "name" <- "sgxiang") // put value("sgxiang") for key("name") into table , support string,number,dictionary,array 40 | 41 | 42 | let objct = try! table.get("name") // get object with key , return YTKObject? 43 | let item = try! table.getItem("name") // get item with key ,return YTKItem? 44 | let allItems = try! table.getAllItems() // get all item with key , return [YTKItem]? 45 | 46 | 47 | try! table.clear() // clear table 48 | try! table.delete("name1","name2") // delete row where key == "name1" and "name2" 49 | try! table.deletePreLike("name") // delete row where key pre like "name" 50 | ``` 51 | 52 | ### YTKItem 53 | 54 | ``` 55 | itemId : itemKey 56 | itemObject : itemValue , is json string 57 | createdTime : item created time 58 | ``` 59 | ### YTKObject 60 | 61 | ``` 62 | objectValue : return AnyObject? 63 | stringValue : return String? 64 | numberValue : return NSNumber? 65 | dictionaryValue : return Dictionary? 66 | arrayValue : return Array? 67 | ``` 68 | 69 | ## Installation 70 | 71 | ### Carthage 72 | 73 | Update Cartfile to include the following: 74 | ``` 75 | github "sgxiang/YTKKeyValueStore_Swift" ~> 0.4.2 76 | ``` 77 | 78 | Run `carthage update` and [add the appropriate framework][Carthage Usage]. 79 | 80 | [Carthage Usage]: https://github.com/Carthage/Carthage#adding-frameworks-to-an-application 81 | 82 | ### CocoaPods 83 | 84 | Update Podfile to include the following: 85 | 86 | ```ruby 87 | use_frameworks! 88 | 89 | pod 'YTKKeyValueStore_Swift', '~> 0.4.2' 90 | ``` 91 | 92 | Run `pod install` 93 | 94 | ### Embedded Framework 95 | 96 | - Add YTKKeyValueStore as a submodule by opening the Terminal, cd-ing into your top-level project directory, and entering the following command: 97 | 98 | ``` 99 | $ git submodule add https://github.com/Sgxiang/YTKKeyValueStore_Swift.git 100 | ``` 101 | - Open the YTKKeyValueStore folder, and drag YTKKeyValueStore.xcodeproj into the file navigator of your app project. 102 | 103 | - 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. 104 | 105 | - Ensure that the deployment target of YTKKeyValueStore.framework matches that of the application target. 106 | 107 | - In the tab bar at the top of that window, open the "Build Phases" panel. 108 | Expand the "Target Dependencies" group, and add YTKKeyValueStore.framework. 109 | 110 | - 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. 111 | 112 | ## Communication 113 | 114 | - Found a bug or have a feature request? [Open an issue](https://github.com/sgxiang/YTKKeyValueStore_Swift/issues). 115 | 116 | - Want to contribute? [Submit a pull request](https://github.com/sgxiang/YTKKeyValueStore_Swift/pulls). 117 | 118 | ## Author 119 | 120 | - [sgxiang](https://twitter.com/sgxiang1992) 121 | 122 | -------------------------------------------------------------------------------- /YTKKeyValueStore.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1A5891AB1A8B4F6200155614 /* YTKKeyValueStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5891AA1A8B4F6200155614 /* YTKKeyValueStore.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 1A5891B11A8B4F6300155614 /* YTKKeyValueStore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A5891A51A8B4F6200155614 /* YTKKeyValueStore.framework */; }; 12 | 1A5891B81A8B4F6300155614 /* YTKKeyValueStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891B71A8B4F6300155614 /* YTKKeyValueStoreTests.swift */; }; 13 | 1A5891C21A8B4F7A00155614 /* YTKKeyValueStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891C11A8B4F7A00155614 /* YTKKeyValueStore.swift */; }; 14 | 1A5891EC1A8B5DB600155614 /* YTKObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891EB1A8B5DB600155614 /* YTKObject.swift */; }; 15 | 1A5891F11A8B5DEE00155614 /* YTKSetter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891F01A8B5DEE00155614 /* YTKSetter.swift */; }; 16 | 1A5891F31A8B5E1B00155614 /* YTKTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891F21A8B5E1B00155614 /* YTKTable.swift */; }; 17 | 1A5891F51A8B5E5D00155614 /* YTKConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891F41A8B5E5D00155614 /* YTKConfig.swift */; }; 18 | 1A5891F71A8B5EBE00155614 /* YTKItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891F61A8B5EBE00155614 /* YTKItem.swift */; }; 19 | 1A81A1671BA80B0400A53DE1 /* YTKError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A81A1661BA80B0400A53DE1 /* YTKError.swift */; }; 20 | 1A9239681C8FCAE600190AF1 /* SQLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9239611C8FCAC600190AF1 /* SQLite.framework */; }; 21 | 1A9239691C8FCAEE00190AF1 /* SQLite.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A9239611C8FCAC600190AF1 /* SQLite.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | 1A21656F1EC9585700EBDF0B /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */; 28 | proxyType = 2; 29 | remoteGlobalIDString = 03A65E5A1C6BB0F50062603F; 30 | remoteInfo = "SQLite tvOS"; 31 | }; 32 | 1A2165711EC9585700EBDF0B /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */; 35 | proxyType = 2; 36 | remoteGlobalIDString = 03A65E631C6BB0F60062603F; 37 | remoteInfo = "SQLiteTests tvOS"; 38 | }; 39 | 1A2165731EC9585700EBDF0B /* PBXContainerItemProxy */ = { 40 | isa = PBXContainerItemProxy; 41 | containerPortal = 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */; 42 | proxyType = 2; 43 | remoteGlobalIDString = A121AC451CA35C79005A31D1; 44 | remoteInfo = "SQLite watchOS"; 45 | }; 46 | 1A5891B21A8B4F6300155614 /* PBXContainerItemProxy */ = { 47 | isa = PBXContainerItemProxy; 48 | containerPortal = 1A58919C1A8B4F6200155614 /* Project object */; 49 | proxyType = 1; 50 | remoteGlobalIDString = 1A5891A41A8B4F6200155614; 51 | remoteInfo = YTKKeyValueStore; 52 | }; 53 | 1A9239601C8FCAC600190AF1 /* PBXContainerItemProxy */ = { 54 | isa = PBXContainerItemProxy; 55 | containerPortal = 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */; 56 | proxyType = 2; 57 | remoteGlobalIDString = EE247AD31C3F04ED00AE3E12; 58 | remoteInfo = "SQLite iOS"; 59 | }; 60 | 1A9239621C8FCAC600190AF1 /* PBXContainerItemProxy */ = { 61 | isa = PBXContainerItemProxy; 62 | containerPortal = 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */; 63 | proxyType = 2; 64 | remoteGlobalIDString = EE247ADD1C3F04ED00AE3E12; 65 | remoteInfo = "SQLiteTests iOS"; 66 | }; 67 | 1A9239641C8FCAC600190AF1 /* PBXContainerItemProxy */ = { 68 | isa = PBXContainerItemProxy; 69 | containerPortal = 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */; 70 | proxyType = 2; 71 | remoteGlobalIDString = EE247B3C1C3F3ED000AE3E12; 72 | remoteInfo = "SQLite Mac"; 73 | }; 74 | 1A9239661C8FCAC600190AF1 /* PBXContainerItemProxy */ = { 75 | isa = PBXContainerItemProxy; 76 | containerPortal = 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */; 77 | proxyType = 2; 78 | remoteGlobalIDString = EE247B451C3F3ED000AE3E12; 79 | remoteInfo = "SQLiteTests Mac"; 80 | }; 81 | /* End PBXContainerItemProxy section */ 82 | 83 | /* Begin PBXCopyFilesBuildPhase section */ 84 | 1A5891D51A8B4FE800155614 /* CopyFiles */ = { 85 | isa = PBXCopyFilesBuildPhase; 86 | buildActionMask = 2147483647; 87 | dstPath = ""; 88 | dstSubfolderSpec = 10; 89 | files = ( 90 | 1A9239691C8FCAEE00190AF1 /* SQLite.framework in CopyFiles */, 91 | ); 92 | runOnlyForDeploymentPostprocessing = 0; 93 | }; 94 | /* End PBXCopyFilesBuildPhase section */ 95 | 96 | /* Begin PBXFileReference section */ 97 | 1A5891A51A8B4F6200155614 /* YTKKeyValueStore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = YTKKeyValueStore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 98 | 1A5891A91A8B4F6200155614 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 99 | 1A5891AA1A8B4F6200155614 /* YTKKeyValueStore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YTKKeyValueStore.h; sourceTree = ""; }; 100 | 1A5891B01A8B4F6300155614 /* YTKKeyValueStoreTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YTKKeyValueStoreTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 101 | 1A5891B61A8B4F6300155614 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 102 | 1A5891B71A8B4F6300155614 /* YTKKeyValueStoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YTKKeyValueStoreTests.swift; sourceTree = ""; }; 103 | 1A5891C11A8B4F7A00155614 /* YTKKeyValueStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YTKKeyValueStore.swift; sourceTree = ""; }; 104 | 1A5891EB1A8B5DB600155614 /* YTKObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YTKObject.swift; sourceTree = ""; }; 105 | 1A5891F01A8B5DEE00155614 /* YTKSetter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YTKSetter.swift; sourceTree = ""; }; 106 | 1A5891F21A8B5E1B00155614 /* YTKTable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YTKTable.swift; sourceTree = ""; }; 107 | 1A5891F41A8B5E5D00155614 /* YTKConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YTKConfig.swift; sourceTree = ""; }; 108 | 1A5891F61A8B5EBE00155614 /* YTKItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YTKItem.swift; sourceTree = ""; }; 109 | 1A81A1661BA80B0400A53DE1 /* YTKError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YTKError.swift; sourceTree = ""; }; 110 | 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SQLite.xcodeproj; path = Vendor/SQLite.swift/SQLite.xcodeproj; sourceTree = SOURCE_ROOT; }; 111 | /* End PBXFileReference section */ 112 | 113 | /* Begin PBXFrameworksBuildPhase section */ 114 | 1A5891A11A8B4F6200155614 /* Frameworks */ = { 115 | isa = PBXFrameworksBuildPhase; 116 | buildActionMask = 2147483647; 117 | files = ( 118 | 1A9239681C8FCAE600190AF1 /* SQLite.framework in Frameworks */, 119 | ); 120 | runOnlyForDeploymentPostprocessing = 0; 121 | }; 122 | 1A5891AD1A8B4F6300155614 /* Frameworks */ = { 123 | isa = PBXFrameworksBuildPhase; 124 | buildActionMask = 2147483647; 125 | files = ( 126 | 1A5891B11A8B4F6300155614 /* YTKKeyValueStore.framework in Frameworks */, 127 | ); 128 | runOnlyForDeploymentPostprocessing = 0; 129 | }; 130 | /* End PBXFrameworksBuildPhase section */ 131 | 132 | /* Begin PBXGroup section */ 133 | 1A58919B1A8B4F6200155614 = { 134 | isa = PBXGroup; 135 | children = ( 136 | 1A5891A71A8B4F6200155614 /* YTKKeyValueStore */, 137 | 1A5891B41A8B4F6300155614 /* YTKKeyValueStoreTests */, 138 | 1A5891A61A8B4F6200155614 /* Products */, 139 | ); 140 | sourceTree = ""; 141 | }; 142 | 1A5891A61A8B4F6200155614 /* Products */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 1A5891A51A8B4F6200155614 /* YTKKeyValueStore.framework */, 146 | 1A5891B01A8B4F6300155614 /* YTKKeyValueStoreTests.xctest */, 147 | ); 148 | name = Products; 149 | sourceTree = ""; 150 | }; 151 | 1A5891A71A8B4F6200155614 /* YTKKeyValueStore */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 1A5891C11A8B4F7A00155614 /* YTKKeyValueStore.swift */, 155 | 1A5891F21A8B5E1B00155614 /* YTKTable.swift */, 156 | 1A5891F01A8B5DEE00155614 /* YTKSetter.swift */, 157 | 1A5891F61A8B5EBE00155614 /* YTKItem.swift */, 158 | 1A5891EB1A8B5DB600155614 /* YTKObject.swift */, 159 | 1A5891F41A8B5E5D00155614 /* YTKConfig.swift */, 160 | 1A81A1661BA80B0400A53DE1 /* YTKError.swift */, 161 | 1A5891AA1A8B4F6200155614 /* YTKKeyValueStore.h */, 162 | 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */, 163 | 1A5891A81A8B4F6200155614 /* Supporting Files */, 164 | ); 165 | path = YTKKeyValueStore; 166 | sourceTree = ""; 167 | }; 168 | 1A5891A81A8B4F6200155614 /* Supporting Files */ = { 169 | isa = PBXGroup; 170 | children = ( 171 | 1A5891A91A8B4F6200155614 /* Info.plist */, 172 | ); 173 | name = "Supporting Files"; 174 | sourceTree = ""; 175 | }; 176 | 1A5891B41A8B4F6300155614 /* YTKKeyValueStoreTests */ = { 177 | isa = PBXGroup; 178 | children = ( 179 | 1A5891B71A8B4F6300155614 /* YTKKeyValueStoreTests.swift */, 180 | 1A5891B51A8B4F6300155614 /* Supporting Files */, 181 | ); 182 | path = YTKKeyValueStoreTests; 183 | sourceTree = ""; 184 | }; 185 | 1A5891B51A8B4F6300155614 /* Supporting Files */ = { 186 | isa = PBXGroup; 187 | children = ( 188 | 1A5891B61A8B4F6300155614 /* Info.plist */, 189 | ); 190 | name = "Supporting Files"; 191 | sourceTree = ""; 192 | }; 193 | 1A92395A1C8FCAC600190AF1 /* Products */ = { 194 | isa = PBXGroup; 195 | children = ( 196 | 1A9239611C8FCAC600190AF1 /* SQLite.framework */, 197 | 1A9239631C8FCAC600190AF1 /* SQLiteTests iOS.xctest */, 198 | 1A9239651C8FCAC600190AF1 /* SQLite.framework */, 199 | 1A9239671C8FCAC600190AF1 /* SQLiteTests Mac.xctest */, 200 | 1A2165701EC9585700EBDF0B /* SQLite.framework */, 201 | 1A2165721EC9585700EBDF0B /* SQLiteTests tvOS.xctest */, 202 | 1A2165741EC9585700EBDF0B /* SQLite.framework */, 203 | ); 204 | name = Products; 205 | sourceTree = ""; 206 | }; 207 | /* End PBXGroup section */ 208 | 209 | /* Begin PBXHeadersBuildPhase section */ 210 | 1A5891A21A8B4F6200155614 /* Headers */ = { 211 | isa = PBXHeadersBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | 1A5891AB1A8B4F6200155614 /* YTKKeyValueStore.h in Headers */, 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | }; 218 | /* End PBXHeadersBuildPhase section */ 219 | 220 | /* Begin PBXNativeTarget section */ 221 | 1A5891A41A8B4F6200155614 /* YTKKeyValueStore */ = { 222 | isa = PBXNativeTarget; 223 | buildConfigurationList = 1A5891BB1A8B4F6300155614 /* Build configuration list for PBXNativeTarget "YTKKeyValueStore" */; 224 | buildPhases = ( 225 | 1A5891A01A8B4F6200155614 /* Sources */, 226 | 1A5891A11A8B4F6200155614 /* Frameworks */, 227 | 1A5891A21A8B4F6200155614 /* Headers */, 228 | 1A5891A31A8B4F6200155614 /* Resources */, 229 | 1A5891D51A8B4FE800155614 /* CopyFiles */, 230 | ); 231 | buildRules = ( 232 | ); 233 | dependencies = ( 234 | ); 235 | name = YTKKeyValueStore; 236 | productName = YTKKeyValueStore; 237 | productReference = 1A5891A51A8B4F6200155614 /* YTKKeyValueStore.framework */; 238 | productType = "com.apple.product-type.framework"; 239 | }; 240 | 1A5891AF1A8B4F6300155614 /* YTKKeyValueStoreTests */ = { 241 | isa = PBXNativeTarget; 242 | buildConfigurationList = 1A5891BE1A8B4F6300155614 /* Build configuration list for PBXNativeTarget "YTKKeyValueStoreTests" */; 243 | buildPhases = ( 244 | 1A5891AC1A8B4F6300155614 /* Sources */, 245 | 1A5891AD1A8B4F6300155614 /* Frameworks */, 246 | 1A5891AE1A8B4F6300155614 /* Resources */, 247 | ); 248 | buildRules = ( 249 | ); 250 | dependencies = ( 251 | 1A5891B31A8B4F6300155614 /* PBXTargetDependency */, 252 | ); 253 | name = YTKKeyValueStoreTests; 254 | productName = YTKKeyValueStoreTests; 255 | productReference = 1A5891B01A8B4F6300155614 /* YTKKeyValueStoreTests.xctest */; 256 | productType = "com.apple.product-type.bundle.unit-test"; 257 | }; 258 | /* End PBXNativeTarget section */ 259 | 260 | /* Begin PBXProject section */ 261 | 1A58919C1A8B4F6200155614 /* Project object */ = { 262 | isa = PBXProject; 263 | attributes = { 264 | LastSwiftUpdateCheck = 0700; 265 | LastUpgradeCheck = 0830; 266 | ORGANIZATIONNAME = sgxiang; 267 | TargetAttributes = { 268 | 1A5891A41A8B4F6200155614 = { 269 | CreatedOnToolsVersion = 6.3; 270 | LastSwiftMigration = 0830; 271 | }; 272 | 1A5891AF1A8B4F6300155614 = { 273 | CreatedOnToolsVersion = 6.3; 274 | LastSwiftMigration = 0830; 275 | }; 276 | }; 277 | }; 278 | buildConfigurationList = 1A58919F1A8B4F6200155614 /* Build configuration list for PBXProject "YTKKeyValueStore" */; 279 | compatibilityVersion = "Xcode 3.2"; 280 | developmentRegion = English; 281 | hasScannedForEncodings = 0; 282 | knownRegions = ( 283 | en, 284 | ); 285 | mainGroup = 1A58919B1A8B4F6200155614; 286 | productRefGroup = 1A5891A61A8B4F6200155614 /* Products */; 287 | projectDirPath = ""; 288 | projectReferences = ( 289 | { 290 | ProductGroup = 1A92395A1C8FCAC600190AF1 /* Products */; 291 | ProjectRef = 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */; 292 | }, 293 | ); 294 | projectRoot = ""; 295 | targets = ( 296 | 1A5891A41A8B4F6200155614 /* YTKKeyValueStore */, 297 | 1A5891AF1A8B4F6300155614 /* YTKKeyValueStoreTests */, 298 | ); 299 | }; 300 | /* End PBXProject section */ 301 | 302 | /* Begin PBXReferenceProxy section */ 303 | 1A2165701EC9585700EBDF0B /* SQLite.framework */ = { 304 | isa = PBXReferenceProxy; 305 | fileType = wrapper.framework; 306 | path = SQLite.framework; 307 | remoteRef = 1A21656F1EC9585700EBDF0B /* PBXContainerItemProxy */; 308 | sourceTree = BUILT_PRODUCTS_DIR; 309 | }; 310 | 1A2165721EC9585700EBDF0B /* SQLiteTests tvOS.xctest */ = { 311 | isa = PBXReferenceProxy; 312 | fileType = wrapper.cfbundle; 313 | path = "SQLiteTests tvOS.xctest"; 314 | remoteRef = 1A2165711EC9585700EBDF0B /* PBXContainerItemProxy */; 315 | sourceTree = BUILT_PRODUCTS_DIR; 316 | }; 317 | 1A2165741EC9585700EBDF0B /* SQLite.framework */ = { 318 | isa = PBXReferenceProxy; 319 | fileType = wrapper.framework; 320 | path = SQLite.framework; 321 | remoteRef = 1A2165731EC9585700EBDF0B /* PBXContainerItemProxy */; 322 | sourceTree = BUILT_PRODUCTS_DIR; 323 | }; 324 | 1A9239611C8FCAC600190AF1 /* SQLite.framework */ = { 325 | isa = PBXReferenceProxy; 326 | fileType = wrapper.framework; 327 | path = SQLite.framework; 328 | remoteRef = 1A9239601C8FCAC600190AF1 /* PBXContainerItemProxy */; 329 | sourceTree = BUILT_PRODUCTS_DIR; 330 | }; 331 | 1A9239631C8FCAC600190AF1 /* SQLiteTests iOS.xctest */ = { 332 | isa = PBXReferenceProxy; 333 | fileType = wrapper.cfbundle; 334 | path = "SQLiteTests iOS.xctest"; 335 | remoteRef = 1A9239621C8FCAC600190AF1 /* PBXContainerItemProxy */; 336 | sourceTree = BUILT_PRODUCTS_DIR; 337 | }; 338 | 1A9239651C8FCAC600190AF1 /* SQLite.framework */ = { 339 | isa = PBXReferenceProxy; 340 | fileType = wrapper.framework; 341 | path = SQLite.framework; 342 | remoteRef = 1A9239641C8FCAC600190AF1 /* PBXContainerItemProxy */; 343 | sourceTree = BUILT_PRODUCTS_DIR; 344 | }; 345 | 1A9239671C8FCAC600190AF1 /* SQLiteTests Mac.xctest */ = { 346 | isa = PBXReferenceProxy; 347 | fileType = wrapper.cfbundle; 348 | path = "SQLiteTests Mac.xctest"; 349 | remoteRef = 1A9239661C8FCAC600190AF1 /* PBXContainerItemProxy */; 350 | sourceTree = BUILT_PRODUCTS_DIR; 351 | }; 352 | /* End PBXReferenceProxy section */ 353 | 354 | /* Begin PBXResourcesBuildPhase section */ 355 | 1A5891A31A8B4F6200155614 /* Resources */ = { 356 | isa = PBXResourcesBuildPhase; 357 | buildActionMask = 2147483647; 358 | files = ( 359 | ); 360 | runOnlyForDeploymentPostprocessing = 0; 361 | }; 362 | 1A5891AE1A8B4F6300155614 /* Resources */ = { 363 | isa = PBXResourcesBuildPhase; 364 | buildActionMask = 2147483647; 365 | files = ( 366 | ); 367 | runOnlyForDeploymentPostprocessing = 0; 368 | }; 369 | /* End PBXResourcesBuildPhase section */ 370 | 371 | /* Begin PBXSourcesBuildPhase section */ 372 | 1A5891A01A8B4F6200155614 /* Sources */ = { 373 | isa = PBXSourcesBuildPhase; 374 | buildActionMask = 2147483647; 375 | files = ( 376 | 1A5891C21A8B4F7A00155614 /* YTKKeyValueStore.swift in Sources */, 377 | 1A81A1671BA80B0400A53DE1 /* YTKError.swift in Sources */, 378 | 1A5891F31A8B5E1B00155614 /* YTKTable.swift in Sources */, 379 | 1A5891F51A8B5E5D00155614 /* YTKConfig.swift in Sources */, 380 | 1A5891F11A8B5DEE00155614 /* YTKSetter.swift in Sources */, 381 | 1A5891EC1A8B5DB600155614 /* YTKObject.swift in Sources */, 382 | 1A5891F71A8B5EBE00155614 /* YTKItem.swift in Sources */, 383 | ); 384 | runOnlyForDeploymentPostprocessing = 0; 385 | }; 386 | 1A5891AC1A8B4F6300155614 /* Sources */ = { 387 | isa = PBXSourcesBuildPhase; 388 | buildActionMask = 2147483647; 389 | files = ( 390 | 1A5891B81A8B4F6300155614 /* YTKKeyValueStoreTests.swift in Sources */, 391 | ); 392 | runOnlyForDeploymentPostprocessing = 0; 393 | }; 394 | /* End PBXSourcesBuildPhase section */ 395 | 396 | /* Begin PBXTargetDependency section */ 397 | 1A5891B31A8B4F6300155614 /* PBXTargetDependency */ = { 398 | isa = PBXTargetDependency; 399 | target = 1A5891A41A8B4F6200155614 /* YTKKeyValueStore */; 400 | targetProxy = 1A5891B21A8B4F6300155614 /* PBXContainerItemProxy */; 401 | }; 402 | /* End PBXTargetDependency section */ 403 | 404 | /* Begin XCBuildConfiguration section */ 405 | 1A5891B91A8B4F6300155614 /* Debug */ = { 406 | isa = XCBuildConfiguration; 407 | buildSettings = { 408 | ALWAYS_SEARCH_USER_PATHS = NO; 409 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 410 | CLANG_CXX_LIBRARY = "libc++"; 411 | CLANG_ENABLE_MODULES = YES; 412 | CLANG_ENABLE_OBJC_ARC = YES; 413 | CLANG_WARN_BOOL_CONVERSION = YES; 414 | CLANG_WARN_CONSTANT_CONVERSION = YES; 415 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 416 | CLANG_WARN_EMPTY_BODY = YES; 417 | CLANG_WARN_ENUM_CONVERSION = YES; 418 | CLANG_WARN_INFINITE_RECURSION = YES; 419 | CLANG_WARN_INT_CONVERSION = YES; 420 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 421 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 422 | CLANG_WARN_UNREACHABLE_CODE = YES; 423 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 424 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 425 | COPY_PHASE_STRIP = NO; 426 | CURRENT_PROJECT_VERSION = 1; 427 | DEBUG_INFORMATION_FORMAT = dwarf; 428 | ENABLE_STRICT_OBJC_MSGSEND = YES; 429 | ENABLE_TESTABILITY = YES; 430 | GCC_C_LANGUAGE_STANDARD = gnu99; 431 | GCC_DYNAMIC_NO_PIC = NO; 432 | GCC_NO_COMMON_BLOCKS = YES; 433 | GCC_OPTIMIZATION_LEVEL = 0; 434 | GCC_PREPROCESSOR_DEFINITIONS = ( 435 | "DEBUG=1", 436 | "$(inherited)", 437 | ); 438 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 439 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 440 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 441 | GCC_WARN_UNDECLARED_SELECTOR = YES; 442 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 443 | GCC_WARN_UNUSED_FUNCTION = YES; 444 | GCC_WARN_UNUSED_VARIABLE = YES; 445 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 446 | MTL_ENABLE_DEBUG_INFO = YES; 447 | ONLY_ACTIVE_ARCH = YES; 448 | SDKROOT = iphoneos; 449 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 450 | TARGETED_DEVICE_FAMILY = "1,2"; 451 | VERSIONING_SYSTEM = "apple-generic"; 452 | VERSION_INFO_PREFIX = ""; 453 | }; 454 | name = Debug; 455 | }; 456 | 1A5891BA1A8B4F6300155614 /* Release */ = { 457 | isa = XCBuildConfiguration; 458 | buildSettings = { 459 | ALWAYS_SEARCH_USER_PATHS = NO; 460 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 461 | CLANG_CXX_LIBRARY = "libc++"; 462 | CLANG_ENABLE_MODULES = YES; 463 | CLANG_ENABLE_OBJC_ARC = YES; 464 | CLANG_WARN_BOOL_CONVERSION = YES; 465 | CLANG_WARN_CONSTANT_CONVERSION = YES; 466 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 467 | CLANG_WARN_EMPTY_BODY = YES; 468 | CLANG_WARN_ENUM_CONVERSION = YES; 469 | CLANG_WARN_INFINITE_RECURSION = YES; 470 | CLANG_WARN_INT_CONVERSION = YES; 471 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 472 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 473 | CLANG_WARN_UNREACHABLE_CODE = YES; 474 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 475 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 476 | COPY_PHASE_STRIP = NO; 477 | CURRENT_PROJECT_VERSION = 1; 478 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 479 | ENABLE_NS_ASSERTIONS = NO; 480 | ENABLE_STRICT_OBJC_MSGSEND = YES; 481 | GCC_C_LANGUAGE_STANDARD = gnu99; 482 | GCC_NO_COMMON_BLOCKS = YES; 483 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 484 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 485 | GCC_WARN_UNDECLARED_SELECTOR = YES; 486 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 487 | GCC_WARN_UNUSED_FUNCTION = YES; 488 | GCC_WARN_UNUSED_VARIABLE = YES; 489 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 490 | MTL_ENABLE_DEBUG_INFO = NO; 491 | SDKROOT = iphoneos; 492 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 493 | TARGETED_DEVICE_FAMILY = "1,2"; 494 | VALIDATE_PRODUCT = YES; 495 | VERSIONING_SYSTEM = "apple-generic"; 496 | VERSION_INFO_PREFIX = ""; 497 | }; 498 | name = Release; 499 | }; 500 | 1A5891BC1A8B4F6300155614 /* Debug */ = { 501 | isa = XCBuildConfiguration; 502 | buildSettings = { 503 | APPLICATION_EXTENSION_API_ONLY = YES; 504 | CLANG_ENABLE_MODULES = YES; 505 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 506 | DEFINES_MODULE = YES; 507 | DYLIB_COMPATIBILITY_VERSION = 1; 508 | DYLIB_CURRENT_VERSION = 1; 509 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 510 | INFOPLIST_FILE = YTKKeyValueStore/Info.plist; 511 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 512 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 513 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 514 | PRODUCT_BUNDLE_IDENTIFIER = "com.sgxiang.$(PRODUCT_NAME:rfc1034identifier)"; 515 | PRODUCT_NAME = "$(TARGET_NAME)"; 516 | SKIP_INSTALL = YES; 517 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 518 | SWIFT_VERSION = 3.0; 519 | }; 520 | name = Debug; 521 | }; 522 | 1A5891BD1A8B4F6300155614 /* Release */ = { 523 | isa = XCBuildConfiguration; 524 | buildSettings = { 525 | APPLICATION_EXTENSION_API_ONLY = YES; 526 | CLANG_ENABLE_MODULES = YES; 527 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 528 | DEFINES_MODULE = YES; 529 | DYLIB_COMPATIBILITY_VERSION = 1; 530 | DYLIB_CURRENT_VERSION = 1; 531 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 532 | INFOPLIST_FILE = YTKKeyValueStore/Info.plist; 533 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 534 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 535 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 536 | PRODUCT_BUNDLE_IDENTIFIER = "com.sgxiang.$(PRODUCT_NAME:rfc1034identifier)"; 537 | PRODUCT_NAME = "$(TARGET_NAME)"; 538 | SKIP_INSTALL = YES; 539 | SWIFT_VERSION = 3.0; 540 | }; 541 | name = Release; 542 | }; 543 | 1A5891BF1A8B4F6300155614 /* Debug */ = { 544 | isa = XCBuildConfiguration; 545 | buildSettings = { 546 | FRAMEWORK_SEARCH_PATHS = ( 547 | "$(SDKROOT)/Developer/Library/Frameworks", 548 | "$(inherited)", 549 | ); 550 | GCC_PREPROCESSOR_DEFINITIONS = ( 551 | "DEBUG=1", 552 | "$(inherited)", 553 | ); 554 | INFOPLIST_FILE = YTKKeyValueStoreTests/Info.plist; 555 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 556 | PRODUCT_BUNDLE_IDENTIFIER = "com.sgxiang.$(PRODUCT_NAME:rfc1034identifier)"; 557 | PRODUCT_NAME = "$(TARGET_NAME)"; 558 | SWIFT_VERSION = 3.0; 559 | }; 560 | name = Debug; 561 | }; 562 | 1A5891C01A8B4F6300155614 /* Release */ = { 563 | isa = XCBuildConfiguration; 564 | buildSettings = { 565 | FRAMEWORK_SEARCH_PATHS = ( 566 | "$(SDKROOT)/Developer/Library/Frameworks", 567 | "$(inherited)", 568 | ); 569 | INFOPLIST_FILE = YTKKeyValueStoreTests/Info.plist; 570 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 571 | PRODUCT_BUNDLE_IDENTIFIER = "com.sgxiang.$(PRODUCT_NAME:rfc1034identifier)"; 572 | PRODUCT_NAME = "$(TARGET_NAME)"; 573 | SWIFT_VERSION = 3.0; 574 | }; 575 | name = Release; 576 | }; 577 | /* End XCBuildConfiguration section */ 578 | 579 | /* Begin XCConfigurationList section */ 580 | 1A58919F1A8B4F6200155614 /* Build configuration list for PBXProject "YTKKeyValueStore" */ = { 581 | isa = XCConfigurationList; 582 | buildConfigurations = ( 583 | 1A5891B91A8B4F6300155614 /* Debug */, 584 | 1A5891BA1A8B4F6300155614 /* Release */, 585 | ); 586 | defaultConfigurationIsVisible = 0; 587 | defaultConfigurationName = Release; 588 | }; 589 | 1A5891BB1A8B4F6300155614 /* Build configuration list for PBXNativeTarget "YTKKeyValueStore" */ = { 590 | isa = XCConfigurationList; 591 | buildConfigurations = ( 592 | 1A5891BC1A8B4F6300155614 /* Debug */, 593 | 1A5891BD1A8B4F6300155614 /* Release */, 594 | ); 595 | defaultConfigurationIsVisible = 0; 596 | defaultConfigurationName = Release; 597 | }; 598 | 1A5891BE1A8B4F6300155614 /* Build configuration list for PBXNativeTarget "YTKKeyValueStoreTests" */ = { 599 | isa = XCConfigurationList; 600 | buildConfigurations = ( 601 | 1A5891BF1A8B4F6300155614 /* Debug */, 602 | 1A5891C01A8B4F6300155614 /* Release */, 603 | ); 604 | defaultConfigurationIsVisible = 0; 605 | defaultConfigurationName = Release; 606 | }; 607 | /* End XCConfigurationList section */ 608 | }; 609 | rootObject = 1A58919C1A8B4F6200155614 /* Project object */; 610 | } 611 | -------------------------------------------------------------------------------- /YTKKeyValueStore.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YTKKeyValueStore.xcodeproj/project.xcworkspace/xcshareddata/YTKKeyValueStore.xcscmblueprint: -------------------------------------------------------------------------------- 1 | { 2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "4A981CE5EBB25D0F76C1CD8B5935247ECC95C653", 3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { 4 | 5 | }, 6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { 7 | "3AE8ED2E684071AF4FB151FA51BF266B82FF45BD" : 0, 8 | "4A981CE5EBB25D0F76C1CD8B5935247ECC95C653" : 0 9 | }, 10 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "F6638221-B3F5-4B3D-B500-7A6199A548C6", 11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { 12 | "3AE8ED2E684071AF4FB151FA51BF266B82FF45BD" : "YTKKeyValueStore_Swift\/Vendor\/SQLite.swift\/", 13 | "4A981CE5EBB25D0F76C1CD8B5935247ECC95C653" : "YTKKeyValueStore_Swift\/" 14 | }, 15 | "DVTSourceControlWorkspaceBlueprintNameKey" : "YTKKeyValueStore", 16 | "DVTSourceControlWorkspaceBlueprintVersion" : 204, 17 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "YTKKeyValueStore.xcodeproj", 18 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ 19 | { 20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/stephencelis\/SQLite.swift.git", 21 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "3AE8ED2E684071AF4FB151FA51BF266B82FF45BD" 23 | }, 24 | { 25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/sgxiang\/YTKKeyValueStore_Swift", 26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "4A981CE5EBB25D0F76C1CD8B5935247ECC95C653" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /YTKKeyValueStore.xcodeproj/xcshareddata/xcschemes/YTKKeyValueStore.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /YTKKeyValueStore/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.4.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /YTKKeyValueStore/YTKConfig.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YTKConfig.swift 3 | // YTKKeyValueStore 4 | // 5 | // Created by ysq on 15/2/11. 6 | // Copyright (c) 2015年 sgxiang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SQLite 11 | 12 | internal let YTKDEBUG = true 13 | 14 | internal let PATH_OF_DOCUMENT : String = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] 15 | 16 | internal let DEFAULT_DB_NAME = "database_swift.sqlite3" 17 | 18 | internal let ID = Expression("id") 19 | internal let JSON = Expression("json") 20 | internal let CREATEDTIME = Expression("createdTime") 21 | -------------------------------------------------------------------------------- /YTKKeyValueStore/YTKError.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YTKError.swift 3 | // YTKKeyValueStore 4 | // 5 | // Created by ysq on 15/9/15. 6 | // Copyright © 2015年 sgxiang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | enum YTKError: Error { 12 | case dbConnectionError 13 | case nameFormatError 14 | case valueNoSupport 15 | } 16 | -------------------------------------------------------------------------------- /YTKKeyValueStore/YTKItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YTKItem.swift 3 | // YTKKeyValueStore 4 | // 5 | // Created by ysq on 15/2/11. 6 | // Copyright (c) 2015年 sgxiang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public struct YTKItem{ 12 | public var itemId : String? 13 | public var itemObject : YTKObject? 14 | public var createdTime : Date? 15 | } 16 | 17 | -------------------------------------------------------------------------------- /YTKKeyValueStore/YTKKeyValueStore.h: -------------------------------------------------------------------------------- 1 | // 2 | // YTKKeyValueStore.h 3 | // YTKKeyValueStore 4 | // 5 | // Created by ysq on 15/2/11. 6 | // Copyright (c) 2015年 sgxiang. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for YTKKeyValueStore. 12 | FOUNDATION_EXPORT double YTKKeyValueStoreVersionNumber; 13 | 14 | //! Project version string for YTKKeyValueStore. 15 | FOUNDATION_EXPORT const unsigned char YTKKeyValueStoreVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /YTKKeyValueStore/YTKKeyValueStore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YTKKeyValueStore_Swift.swift 3 | // YTKKeyValueStore 4 | // 5 | // Created by ysq on 14/12/15. 6 | // Copyright (c) 2014年 TangQiao. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SQLite 11 | 12 | public class YTKKeyValueStore{ 13 | 14 | private var db : Connection? 15 | 16 | private init(dbPath : String!) { 17 | db = try! Connection(dbPath) 18 | } 19 | 20 | convenience public init(_ dbName : String! = DEFAULT_DB_NAME , path : String! = PATH_OF_DOCUMENT) throws{ 21 | 22 | self.init(dbPath:"\(path!)/\(dbName!)") 23 | 24 | guard db != nil else{ 25 | throw YTKError.dbConnectionError 26 | } 27 | 28 | } 29 | 30 | public subscript (tableName : String!) -> YTKTable{ 31 | return YTKTable(db: self.db, tableName) 32 | } 33 | 34 | public func createTable(tableName:String!) throws{ 35 | 36 | guard YTKTable.checkTableName(tableName) else{ 37 | throw YTKError.nameFormatError 38 | } 39 | 40 | do{ 41 | try db?.run(Table(tableName).create(ifNotExists: true){ t in 42 | t.column(ID,primaryKey:true) 43 | t.column(JSON) 44 | t.column(CREATEDTIME,defaultValue:Date()) 45 | }) 46 | }catch let error{ 47 | print("failed to create table : \(tableName)") 48 | throw error 49 | } 50 | 51 | } 52 | 53 | public func dropTable(tableName:String!) throws{ 54 | 55 | guard YTKTable.checkTableName(tableName) else{ 56 | throw YTKError.nameFormatError 57 | } 58 | 59 | do{ 60 | try db?.run(Table(tableName).drop(ifExists: false)) 61 | }catch let error{ 62 | print("failed to drop table : \(tableName)") 63 | throw error 64 | } 65 | 66 | } 67 | 68 | 69 | } 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /YTKKeyValueStore/YTKObject.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YTKObject.swift 3 | // YTKKeyValueStore 4 | // 5 | // Created by ysq on 15/2/11. 6 | // Copyright (c) 2015年 sgxiang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | //MARK: - 数据库的对象类型 12 | 13 | public struct YTKObject{ 14 | internal var value : AnyObject? 15 | 16 | public var objectValue : AnyObject?{ 17 | get{ 18 | return self.value 19 | } 20 | } 21 | 22 | public var stringValue : String? { 23 | get{ 24 | return self.value as? String 25 | } 26 | } 27 | 28 | public var numberValue : NSNumber?{ 29 | 30 | get{ 31 | if self.value == nil { return nil} 32 | 33 | if let num = self.value as? NSNumber{ 34 | return num 35 | }else{ 36 | 37 | do{ 38 | let result: Any? = try JSONSerialization.jsonObject(with: self.value!.data(using: String.Encoding.utf8.rawValue)!, options: .allowFragments) 39 | if let num = result as? [NSNumber]{ 40 | return num[0] 41 | }else{ 42 | return nil 43 | } 44 | }catch{ 45 | print("faild to get json data") 46 | return nil 47 | } 48 | 49 | } 50 | } 51 | 52 | } 53 | 54 | public var dictionaryValue : Dictionary?{ 55 | get{ 56 | if self.value == nil { return nil} 57 | 58 | do{ 59 | let result: Any? = try JSONSerialization.jsonObject(with: self.value!.data(using: String.Encoding.utf8.rawValue)!, options: .allowFragments) 60 | if let dic = result as? Dictionary{ 61 | return dic 62 | }else{ 63 | return nil 64 | } 65 | }catch{ 66 | print("faild to get json data") 67 | return nil 68 | } 69 | 70 | } 71 | } 72 | 73 | 74 | public var arrayValue : Array?{ 75 | get{ 76 | if self.value == nil { return nil} 77 | 78 | do{ 79 | let result: Any? = try JSONSerialization.jsonObject(with: self.value!.data(using: String.Encoding.utf8.rawValue)!, options: .allowFragments) 80 | if let dic = result as? Array{ 81 | return dic 82 | }else{ 83 | return nil 84 | } 85 | }catch{ 86 | print("faild to get json data") 87 | return nil 88 | } 89 | } 90 | } 91 | 92 | 93 | } 94 | -------------------------------------------------------------------------------- /YTKKeyValueStore/YTKSetter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YTKSetter.swift 3 | // YTKKeyValueStore 4 | // 5 | // Created by ysq on 15/2/11. 6 | // Copyright (c) 2015年 sgxiang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public struct YTKSetter { 12 | internal var objectId : String! 13 | fileprivate var object : Any! 14 | public init(_ id : String!, _ object : Any!){ 15 | self.objectId = id 16 | self.object = object 17 | } 18 | 19 | internal var jsonString : String?{ 20 | get{ 21 | 22 | if object is String{ 23 | return (object as! String) 24 | }else{ 25 | 26 | var sqlObject : Any? 27 | 28 | if let number = self.object as? NSNumber{ 29 | sqlObject = [number] 30 | }else if let arrayObject = self.object as? [Any]{ 31 | sqlObject = arrayObject as AnyObject 32 | }else if let dictionaryObject = self.object as? Dictionary{ 33 | sqlObject = dictionaryObject as AnyObject 34 | }else{ 35 | return nil 36 | } 37 | 38 | do{ 39 | let data = try JSONSerialization.data(withJSONObject: sqlObject!, options: JSONSerialization.WritingOptions(rawValue: 0)) 40 | return NSString(data: data, encoding: String.Encoding.utf8.rawValue) as String? 41 | }catch{ 42 | print("faild to get json data") 43 | return nil 44 | } 45 | } 46 | 47 | } 48 | } 49 | } 50 | 51 | 52 | infix operator <- : MultiplicationPrecedence 53 | precedencegroup MultiplicationPrecedence { 54 | associativity: left 55 | higherThan: AdditionPrecedence 56 | } 57 | 58 | public func <- (objectId: String!, object: Any!) -> YTKSetter{ 59 | return YTKSetter(objectId , object) 60 | } 61 | -------------------------------------------------------------------------------- /YTKKeyValueStore/YTKTable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YTKTable.swift 3 | // YTKKeyValueStore 4 | // 5 | // Created by ysq on 15/2/11. 6 | // Copyright (c) 2015年 sgxiang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SQLite 11 | 12 | 13 | public struct YTKTable{ 14 | 15 | public let name : String? 16 | 17 | public var isExists : Bool { 18 | get{ 19 | guard tableHandle != nil else{ 20 | return false 21 | } 22 | do{ 23 | return try db?.scalar("SELECT EXISTS (SELECT * FROM sqlite_master WHERE type = 'table' AND name = ?)",name) as! Int64 > 0 24 | }catch _{ 25 | return false 26 | } 27 | } 28 | } 29 | 30 | internal let db : Connection? 31 | internal let tableHandle : Table? 32 | 33 | internal init(db : Connection?, _ tableName : String!){ 34 | if YTKTable.checkTableName(tableName){ 35 | self.db = db 36 | self.name = tableName 37 | self.tableHandle = Table(tableName) 38 | }else{ 39 | self.db = nil 40 | self.name = nil 41 | self.tableHandle = nil 42 | } 43 | } 44 | 45 | internal static func checkTableName(_ tableName : String!)->Bool{ 46 | if tableName.contains(" "){ 47 | print("table name : \(tableName) format error") 48 | return false 49 | } 50 | return true 51 | } 52 | 53 | public func clear() throws ->Int{ 54 | 55 | do{ 56 | let changes = try db?.run(tableHandle!.delete()) ?? 0 57 | print("table : \(name ?? "") number of deleted rows : \(changes)") 58 | return changes 59 | }catch let error{ 60 | throw error 61 | } 62 | 63 | } 64 | 65 | public func delete(_ objectIds : String... ) throws -> Int{ 66 | 67 | do{ 68 | let changes = try db?.run(tableHandle!.filter(objectIds.contains(ID)).delete()) ?? 0 69 | print("table : \(name ?? "") number of deleted rows : \(changes)") 70 | return changes 71 | }catch let error{ 72 | throw error 73 | } 74 | 75 | } 76 | 77 | public func deletePreLike(_ objectId : String!) throws -> Int{ 78 | 79 | do{ 80 | let changes = try db?.run(tableHandle!.filter(ID.like("\(objectId)%")).delete()) ?? 0 81 | print("table : \(name ?? "") number of deleted rows : \(changes)") 82 | return changes 83 | }catch let error{ 84 | throw error 85 | } 86 | } 87 | 88 | fileprivate enum YTKKeyValueType{ 89 | case string,number,object 90 | } 91 | 92 | fileprivate static func valueWithType(_ object : AnyObject!)->YTKKeyValueType{ 93 | if object is String{ 94 | return .string 95 | }else if (object as? NSNumber) != nil{ 96 | return .number 97 | }else{ 98 | return .object 99 | } 100 | } 101 | 102 | public func put( _ set : YTKSetter ) throws{ 103 | 104 | guard let jsonString : String = set.jsonString else{ 105 | throw YTKError.valueNoSupport 106 | } 107 | 108 | let query = tableHandle!.filter(ID == set.objectId).limit(1) 109 | do{ 110 | if let filter = try db?.prepare(query){ 111 | if filter.makeIterator().next() == nil{ 112 | do{ 113 | try db?.run( tableHandle!.insert(ID <- set.objectId,JSON <- jsonString,CREATEDTIME <- Date()) ) 114 | print("[insert] id : \(set.objectId) jsonString : \(set.jsonString!)") 115 | }catch let error{ 116 | throw error 117 | } 118 | }else{ 119 | do{ 120 | try db?.run(query.update(JSON <- jsonString,CREATEDTIME <- Date())) 121 | print("[update] id : \(set.objectId) jsonString : \(set.jsonString!)") 122 | }catch let error{ 123 | throw error 124 | } 125 | } 126 | } 127 | }catch let error{ 128 | throw error 129 | } 130 | 131 | } 132 | 133 | public func get( _ objectId : String! ) throws -> YTKObject?{ 134 | do{ 135 | if let item = try self.getItem(objectId){ 136 | return item.itemObject 137 | } 138 | }catch let error{ 139 | throw error 140 | } 141 | return nil 142 | } 143 | 144 | public func getItem(_ objectId :String!) throws ->YTKItem?{ 145 | do{ 146 | if let filter = try db?.prepare( tableHandle!.filter(ID == objectId).limit(1) ){ 147 | for v in filter{ 148 | var item = YTKItem() 149 | item.itemId = objectId 150 | item.itemObject = YTKObject(value: v[JSON] as AnyObject ) 151 | item.createdTime = v.get(CREATEDTIME) 152 | return item 153 | } 154 | } 155 | }catch let error{ 156 | throw error 157 | } 158 | return nil 159 | } 160 | 161 | public func getAllItems() throws ->[YTKItem]{ 162 | 163 | var result : [YTKItem] = [] 164 | do{ 165 | if let filter = try db?.prepare(tableHandle!){ 166 | for vs in filter{ 167 | var item = YTKItem() 168 | item.itemId = vs[ID] 169 | item.itemObject = YTKObject(value:vs[JSON] as AnyObject) 170 | item.createdTime = vs.get(CREATEDTIME) 171 | result.append(item) 172 | } 173 | } 174 | }catch let error{ 175 | throw error 176 | } 177 | return result 178 | } 179 | 180 | 181 | } 182 | -------------------------------------------------------------------------------- /YTKKeyValueStoreTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /YTKKeyValueStoreTests/YTKKeyValueStoreTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YTKKeyValueStore_SwiftTests.swift 3 | // YTKKeyValueStore_SwiftTests 4 | // 5 | // Created by ysq on 14/12/15. 6 | // Copyright (c) 2014年 ysq. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | import YTKKeyValueStore 12 | 13 | class YTKKeyValueStoreTests : XCTestCase { 14 | 15 | fileprivate var _store : YTKKeyValueStore! 16 | fileprivate var _table : YTKTable! 17 | 18 | override func setUp() { 19 | super.setUp() 20 | 21 | do{ 22 | _store = try YTKKeyValueStore("dbtest.sqlite3") 23 | }catch let error as NSError{ 24 | print(error.localizedDescription) 25 | return 26 | } 27 | 28 | do{ 29 | try _store.createTable(tableName: "test_table") 30 | _table = _store["test_table"] 31 | }catch let error as NSError{ 32 | print(error.localizedDescription) 33 | return 34 | } 35 | 36 | } 37 | 38 | override func tearDown() { 39 | _ = try! _table.clear() 40 | try! _store.dropTable(tableName: "test_table") 41 | super.tearDown() 42 | } 43 | 44 | func testSave(){ 45 | 46 | let str = "abc" 47 | let num1 : NSNumber = 1 48 | let num2 : NSNumber = 1.3 49 | let user : Dictionary = ["id":1 as AnyObject , "name" : "tangqiao" as AnyObject , "age" : 30 as AnyObject] 50 | 51 | try! _table.put("str" <- str ) 52 | try! _table.put("num1" <- num1) 53 | try! _table.put("num2" <- num2) 54 | try! _table.put("user" <- user) 55 | 56 | 57 | if let result = try! _table.get("str")?.stringValue{ 58 | XCTAssertEqual(str, result) 59 | }else{ 60 | XCTAssertFalse(true) 61 | } 62 | 63 | if let result = try! _table.get("num1")?.numberValue{ 64 | XCTAssertEqual(num1, result) 65 | }else{ 66 | XCTAssertFalse(true) 67 | } 68 | 69 | if let result = try! _table.get("num2")?.numberValue{ 70 | XCTAssertEqual(num2, result) 71 | }else{ 72 | XCTAssertFalse(true) 73 | } 74 | 75 | if let result = try! _table.get("user")?.dictionaryValue{ 76 | XCTAssertEqual(user["id"] as? Int, result["id"] as? Int) 77 | XCTAssertEqual(user["name"] as? String, result["name"] as? String) 78 | XCTAssertEqual(user["age"] as? Int, result["age"] as? Int) 79 | }else{ 80 | XCTAssertFalse(true) 81 | } 82 | 83 | if let _ = try! _table.get("user!")?.dictionaryValue{ 84 | XCTAssertFalse(true) 85 | }else{ 86 | XCTAssertTrue(true) 87 | } 88 | 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /YTKKeyValueStore_Swift.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "YTKKeyValueStore_Swift" 3 | s.version = "0.4.2" 4 | s.summary = "A simple Key-Value storage tool, using Sqlite as backend." 5 | s.homepage = "https://github.com/sgxiang/YTKKeyValueStore_Swift" 6 | s.license = "MIT" 7 | s.author = { "sgxiang" => "690228918@qq.com" } 8 | s.platform = :ios, '9.0' 9 | s.source = { :git => "https://github.com/sgxiang/YTKKeyValueStore_Swift.git", :tag => "0.4.2" } 10 | s.source_files = "YTKKeyValueStore/*.swift" 11 | s.requires_arc = true 12 | s.module_name = 'YTKKeyValueStore' 13 | s.dependency "SQLite.swift", "~> 0.11.3" 14 | end --------------------------------------------------------------------------------