iOS 数据库 canDB.swift

码农软件 · 软件分类 · iOS 数据库 · 2019-05-22 08:57:34

软件介绍

canDB.swift 是一个框架,作用类似 nonSQL 的数据库,但运作在 sqlite(FMDB) 。

    // loading the json
    let filePath = NSBundle.mainBundle().pathForResource("data", ofType:"json")    let data = NSData(contentsOfFile:filePath!, options:NSDataReadingOptions.DataReadingUncached, error:nil)    let dataArray:Array = NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.allZeros, error: nil) as! Array<Dictionary<String, String>>

    // singleton instance
    let storeInstance = canDB.sharedInstance    // saving the data, the can is automatically created if not exists
    storeInstance.saveData("Person", data: dataArray, idString: kCanDBDefaultIdString, error: nil)    // adding the index for future queries and reindexing the table
    storeInstance.addIndex("Person", indexes: ["Name"], error: nil)
    storeInstance.reIndex("Person", idString: kCanDBDefaultIdString)    let result = storeInstance.loadData("Person")    for item in result {        for (key, value) in (item as! NSDictionary) {
            println("\(key): \(value)")
        }
    }    // custom query using the previous created index "Name"
    let resultWithQuery = storeInstance.loadDataWithQuery("SELECT * FROM Person WHERE Name='John'")    for item in resultWithQuery {        for (key, value) in (item as! NSDictionary) {
            println("\(key): \(value)")
        }
    }

    storeInstance.removeDataForId("Person", idString: kCanDBDefaultIdString, idsToDelete: ["17", "19"], error: nil)

本文地址:https://codercto.com/soft/d/6280.html

挑战编程

挑战编程

斯基纳 / 刘汝佳 / 2009-7 / 39.00元

《挑战编程:程序设计竞赛训练手册》分为14章,分别介绍在线评测系统的基本使用方法、数据结构、字符串、排序、算术与代数、组合数学、数论、回溯法、图遍历、图算法、动态规划、网格、几何,以及计算几何,并在附录中介绍了一些著名的程序设计竞赛以及相应的备赛建议与比赛技巧。每章的正文用十余页的篇幅覆盖了该领域最核心的概念和算法,然后给出八道可在线提交的完整编程挑战题目供读者练习。 全书内容紧凑、信息量大......一起来看看 《挑战编程》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具