| cocos2d-x 3.0 |
)- 类列表 - 类索引 - 类继承关系 - 类成员
全部) 类) 命名空间) 文件) 函数) 变量) 类型定义) 枚举) 枚举值) 属性) 友元) 宏定义) 组) 页)
Public 成员函数 | 静态 Public 成员函数 | 所有成员列表
UserDefault类 参考 Data Storage
UserDefault是个微型数据库,你可以将基础数据类型存储在里面或从里面读取出来. 更多…
#include
| ## Public 成员函数 | |
| bool | getBoolForKey (const char pKey) |
| 读取bool值,如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为false NA 更多… | |
| bool | getBoolForKey (const char pKey, bool defaultValue) |
| NA 更多… | |
| int | getIntegerForKey (const char pKey) |
| 读取integer值,如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为0 NA 更多… | |
| int | getIntegerForKey (const char pKey, int defaultValue) |
| NA 更多… | |
| float | getFloatForKey (const char pKey) |
| 读取float值,如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为0.0f. 更多… | |
| float | getFloatForKey (const char pKey, float defaultValue) |
| NA 更多… | |
| double | getDoubleForKey (const char pKey) |
| 读取double值,如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为0.0. 更多… | |
| double | getDoubleForKey (const char pKey, double defaultValue) |
| NA 更多… | |
| std::string | getStringForKey (const char pKey) |
| 读取string值,如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为"". 更多… | |
| std::string | getStringForKey (const char pKey, const std::string &defaultValue) |
| NA 更多… | |
| Data | getDataForKey (const char pKey) |
| 读取基于key的二进制数据(binary data),如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为null. 更多… | |
| Data | getDataForKey (const char pKey, const Data &defaultValue) |
| NA NA 更多… | |
| void | setBoolForKey (const char pKey, bool value) |
| 存储bool值 NA 更多… | |
| void | setIntegerForKey (const char pKey, int value) |
| 存储integer值 NA 更多… | |
| void | setFloatForKey (const char pKey, float value) |
| 存储float值 NA 更多… | |
| void | setDoubleForKey (const char pKey, double value) |
| 存储double值 NA 更多… | |
| void | setStringForKey (const char pKey, const std::string &value) |
| 存储string值 NA 更多… | |
| void | setDataForKey (const char pKey, const Data &value) |
| 存储二进制数据(binary data) NA NA 更多… | |
| void | flush () |
| 将内容保存到xml文件 NA 更多… | |
| ## 静态 Public 成员函数 | |
| static UserDefault | getInstance () |
| 返回singleton NA NA 更多… | |
| static void | destroyInstance () |
| NA 更多… | |
| static CC_DEPRECATED_ATTRIBUTE UserDefault | sharedUserDefault () |
| static CC_DEPRECATED_ATTRIBUTE void | purgeSharedUserDefault () |
| NA 更多… | |
| static const std::string & | getXMLFilePath () |
| NA 更多… | |
| static bool | isXMLFileExist () |
| NA 更多… | |
详细描述
UserDefault是个微型数据库,你可以将基础数据类型存储在里面或从里面读取出来.
例如:setBoolForKey("played", true)是将一个bool值存储进去, 其key是"played",因此你可以通过getBoolForKey("played")从数据库中读取该bool值
其支持的基础数据类型如下: bool, int, float, double, string
成员函数说明
| static |
NA
| void flush | ( | ) |
将内容保存到xml文件 NA
| bool getBoolForKey | ( | const char * | pKey | ) |
读取bool值,如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为false NA
| bool getBoolForKey | ( | const char * | pKey, |
| bool | defaultValue | ||
| ) |
NA
| Data getDataForKey | ( | const char * | pKey | ) |
读取基于key的二进制数据(binary data),如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为null.
NA NA
| Data getDataForKey | ( | const char * | pKey, |
| const Data & | defaultValue | ||
| ) |
NA NA
| double getDoubleForKey | ( | const char * | pKey | ) |
读取double值,如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为0.0.
NA
| double getDoubleForKey | ( | const char * | pKey, |
| double | defaultValue | ||
| ) |
NA
| float getFloatForKey | ( | const char * | pKey | ) |
读取float值,如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为0.0f.
NA
| float getFloatForKey | ( | const char * | pKey, |
| float | defaultValue | ||
| ) |
NA
| static |
返回singleton NA NA
| int getIntegerForKey | ( | const char * | pKey | ) |
读取integer值,如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为0 NA
| int getIntegerForKey | ( | const char * | pKey, |
| int | defaultValue | ||
| ) |
NA
| std::string getStringForKey | ( | const char * | pKey | ) |
读取string值,如果这个key不存在,将返回默认值 你可以设置默认值,或不设置则为"".
NA
| std::string getStringForKey | ( | const char * | pKey, |
| const std::string & | defaultValue | ||
| ) |
NA
| static |
NA
| static |
NA
| static |
NA
| void setBoolForKey | ( | const char * | pKey, |
| bool | value | ||
| ) |
存储bool值 NA
| void setDataForKey | ( | const char * | pKey, |
| const Data & | value | ||
| ) |
存储二进制数据(binary data) NA NA
| void setDoubleForKey | ( | const char * | pKey, |
| double | value | ||
| ) |
存储double值 NA
| void setFloatForKey | ( | const char * | pKey, |
| float | value | ||
| ) |
存储float值 NA
| void setIntegerForKey | ( | const char * | pKey, |
| int | value | ||
| ) |
存储integer值 NA
| void setStringForKey | ( | const char * | pKey, |
| const std::string & | value | ||
| ) |
存储string值 NA
| static |
- 弃用:
- . 使用getInstace()代替 NA NA
该类的文档由以下文件生成:
- /Users/zeroyang/Documents/github/cocos2d-x/cocos/2d/CCUserDefault.h
- cocos2d
- UserDefault
- 生成于 2014年 五月 29日 星期四 09:41:53 , 为 cocos2d-x使用
1.8.6
