UserDefault
2015-07-30 17:51
357 查看
CCLOG("********************** init value ***********************"); // set default value UserDefault::getInstance()->setStringForKey("string", "value1"); UserDefault::getInstance()->setIntegerForKey("integer", 10); UserDefault::getInstance()->setFloatForKey("float", 2.3f); UserDefault::getInstance()->setDoubleForKey("double", 2.4); UserDefault::getInstance()->setBoolForKey("bool", true); // print value std::string ret = UserDefault::getInstance()->getStringForKey("string"); CCLOG("string is %s", ret.c_str()); double d = UserDefault::getInstance()->getDoubleForKey("double"); CCLOG("double is %f", d); int i = UserDefault::getInstance()->getIntegerForKey("integer"); CCLOG("integer is %d", i); float f = UserDefault::getInstance()->getFloatForKey("float"); CCLOG("float is %f", f); bool b = UserDefault::getInstance()->getBoolForKey("bool"); if (b) { CCLOG("bool is true"); } else { CCLOG("bool is false"); } //CCUserDefault::getInstance()->flush(); CCLOG("********************** after change value ***********************"); // change the value UserDefault::getInstance()->setStringForKey("string", "value2"); UserDefault::getInstance()->setIntegerForKey("integer", 11); UserDefault::getInstance()->setFloatForKey("float", 2.5f); UserDefault::getInstance()->setDoubleForKey("double", 2.6); UserDefault::getInstance()->setBoolForKey("bool", false); UserDefault::getInstance()->flush(); // print value ret = UserDefault::getInstance()->getStringForKey("string"); CCLOG("string is %s", ret.c_str()); d = UserDefault::getInstance()->getDoubleForKey("double"); CCLOG("double is %f", d); i = UserDefault::getInstance()->getIntegerForKey("integer"); CCLOG("integer is %d", i); f = UserDefault::getInstance()->getFloatForKey("float"); CCLOG("float is %f", f); b = UserDefault::getInstance()->getBoolForKey("bool"); if (b) { CCLOG("bool is true"); } else { CCLOG("bool is false"); }
相关文章推荐
- Junit-12
- Ubuntu终端Terminal常用快捷键
- 枚举定义的两种方法
- java.lang.IllegalArgumentException:No view found for id for fragment 的解决
- 多IDC数据分布--MySQL多机房部署 - 学习笔记 - 51CTO技术博客
- @清晰掉 C++ 中的 enum 结构在内存中是怎么存储的?
- 设计模式之 策略模式
- Android重启应用程序代码
- Windows批处理:自动检查服务器连通性
- mongodb源码分析
- Unity如何在Android上弹出通知消息
- Linux 下的 CONFIG_OF 选项
- Oracle中merge into的使用
- cocos2dx之商店源码
- iOS 实时定位功能
- 数据行转列实例
- QT事件研究的文章
- Corona
- ASP.NET MVC - Bug奇遇之ValidationAttribute
- 属性的小问题