使用 import ROKKeyValue
将框架导入到文件中,以使用 ROKKeyValue。
每个方法都允许你提供一个要保存键的替代 Realm。
ROKKeyValue.put("test", bool: false)
ROKKeyValue.put("date", date: NSDate())
ROKKeyValue.put("double", double: 1.5)
ROKKeyValue.put("float", float: 9.12)
ROKKeyValue.put("int", int: 1)
ROKKeyValue.put("string", string: "My String Key")
如果其中一个键已存在,ROKKeyValue 会直接用新值更新现有的键。
ROKKeyValue.getDouble("Double")
ROKKeyValue.getDouble("Double", defaultValue: 1.1)
ROKKeyValue.getFloat("Float")
ROKKeyValue.getFloat("Float", defaultValue: 1.1)
ROKKeyValue.getInt("Int")
ROKKeyValue.getInt("Int", defaultValue: 1)
ROKKeyValue.getBool("Bool")
ROKKeyValue.getBool("Bool", defaultValue: false)
ROKKeyValue.getDate("Date")
ROKKeyValue.getDate("keDatey", defaultValue: NSDate())
ROKKeyValue.getString("String")
ROKKeyValue.getString("String", defaultValue: "")
使用 ROKKeyValue.getBool("Bool", defaultValue: false)
会返回指定的 defaultValue
如果不存在。调用 ROKKeyValue.getBool("Bool")
会返回对应的选择数据类型的零或空值。
ROKKeyValue.remove("key")
获取给定 realm 中的键的总数
ROKKeyValue.entryCount()
获取“原始”键作为 Object
ROKKeyValue.getRaw("test")
ROKKeyValue 依赖于 Realm
和 iOS 8.0。它目前仅适用于 Swift 1.2。计划有一个 Swift 2.0 分支。
ROKKeyValue 通过 CocoaPods 提供。要安装,只需将以下行添加到你的 Podfile 中
pod "ROKKeyValue"
Roman Klauke, [email protected]
ROKKeyValue 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。