Cocos2d3.0 制作PList文件
auto root = Dictionary::create();
auto string = String::create("string element value");
root->setObject(string, "string element key"); auto array = Array::create(); auto dictInArray = Dictionary::create();
dictInArray->setObject(String::create("string in dictInArray value 0"), "string in dictInArray key 0");
dictInArray->setObject(String::create("string in dictInArray value 1"), "string in dictInArray key 1");
array->addObject(dictInArray); array->addObject(String::create("string in array")); auto arrayInArray = Array::create();
arrayInArray->addObject(String::create("string 0 in arrayInArray"));
arrayInArray->addObject(String::create("string 1 in arrayInArray"));
array->addObject(arrayInArray); root->setObject(array, "array"); auto dictInDict = Dictionary::create();
dictInDict->setObject(String::create("string in dictInDict value"), "string in dictInDict key"); //add boolean to the plist
auto booleanObject = Bool::create(true);
dictInDict->setObject(booleanObject, "bool"); //add interger to the plist
auto intObject = Integer::create(1024);
dictInDict->setObject(intObject, "integer"); //add float to the plist
auto floatObject = Float::create(1024.1024f);
dictInDict->setObject(floatObject, "float"); //add double to the plist
auto doubleObject = Double::create(1024.123);
dictInDict->setObject(doubleObject, "double"); root->setObject(dictInDict, "dictInDict, Hello World"); // end with /
std::string writablePath = FileUtils::getInstance()->getWritablePath();
std::string fullPath = writablePath + "text.plist";
if(root->writeToFile(fullPath.c_str()))
log("see the plist file at %s", fullPath.c_str());
else
log("write plist file failed"); auto loadDict = __Dictionary::createWithContentsOfFile(fullPath.c_str());
auto loadDictInDict = (__Dictionary*)loadDict->objectForKey("dictInDict, Hello World");
auto boolValue = (__String*)loadDictInDict->objectForKey("bool");
CCLOG("%s",boolValue->getCString());
auto floatValue = (__String*)loadDictInDict->objectForKey("float");
CCLOG("%s",floatValue->getCString());
auto intValue = (__String*)loadDictInDict->objectForKey("integer");
CCLOG("%s",intValue->getCString());
auto doubleValue = (__String*)loadDictInDict->objectForKey("double");
CCLOG("%s",doubleValue->getCString());
Cocos2d3.0 制作PList文件的更多相关文章
- 回忆基础:制作plist文件
-(void)creatPlistFileWithArr:(NSArray *)array{ //将字典保存到document文件->获取appdocument路径 NSString *docP ...
- 还原TexturePacker plist 文件以及图片的方法 (切开各小图片)
原地址:http://blog.csdn.net/linuxchen/article/details/16865645 Python 脚本:(来自网络) unpack_plist.py 命令行: py ...
- 3种方法快速制作tpk文件 [转]
tpk是ArcGIS10.1推出的一种新的数据文件类型,主要是用于将切片文件打包形成离线地图包,tpk可以在ArcGIS Runtime或者ArcGIS for Android/iOS中作为切片底图被 ...
- plist文件、NSUserDefault 对文件进行存储的类、json格式解析
========================== 文件操作 ========================== Δ一 .plist文件 .plist文件是一个属性字典数组的一个文件: .plis ...
- ios开发之Info.plist文件相关配置
前言:在iOS开发中有些情况下需要对Info.plist文件进行配置,以下介绍几种相关配置.以后遇到需要配置的再更新... 开发环境:swift3.0.1,Xcode8.1 一,项目中需要使用第三方字 ...
- Excel文件转plist文件出现的文件编码问题
今天在测试时遇到了需要将大量整理好的Excel数据转换为plist文件的情况.百度了一下教程,发现虽然别人也遇到过类似的情况,但是有些讲的还是不够细致.所以做如下整理. 百度到的内容中有使用Mes ...
- IOS学习笔记之获取Plist文件读取数据
@property(nonatomic,strong) NSArray *pic; //创建数组属性 @property(nonatomic,assign) int index; //创建索引属性 @ ...
- NSIS使用教程(安装包制作安装文件教程,如何封装打包文件) 中文版
nsis中文版(Nullsoft Scriptable Install System)是一个专业的开源的可以用来封闭Windows程序的实用工具,是一个开源的 Windows 系统下安装程序制作程序. ...
- iOS开发——UI基础-懒加载,plist文件,字典转模型,自定义view
一.懒加载 只有使用到了商品数组才会创建数组 保证数组只会被创建一次 只要能够保证数组在使用时才创建, 并且只会创建一次, 那么我们就称之为懒加载 lazy - (void)viewDidLoad 控 ...
随机推荐
- linq 在查询表达式中处理 null 值
此示例显示如何在源集合中处理可能的 null 值. IEnumerable<T> 等对象集合可包含值为 null 的元素. 如果源集合为 null 或包含值为 null 的元素,并且查询不 ...
- jQuery选择器(层级选择器)第二节
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- oracle导入TYPE对象报错ORA-02304
Type是我们经常使用的数据库对象结构.我们在实际中,可以单独定义type类型,之后在PL/SQL代码或者数据表中使用. 在一个偶然的机会让笔者发现使用Type类型在数据exp/imp中的麻烦.当我们 ...
- c#正则表达式应用实例
两种使用方法: 1.在文本输入框后加入正则表达式验证控件Regularexpression_r_rValidator.此种方法适用于WebForm中.在Validationexpression_r_r ...
- [转载] su和sudo
转载自http://www.cnblogs.com/haichuan3000/articles/2123633.html Mandriva 说也奇怪,用root登录的用户比一般用户还难用,当初用FC6 ...
- 原生JS—实现图片循环切换的两种方法
今天我们主要讲讲如何使用原生JS实现图片的循环切换的方法.多余的话我们就不多说了,我们一个一个开始讲吧. 1 原生JS实现图片循环切换 -- 方法一 在上栗子之前我们先简单介绍一下所用的一些知识点. ...
- 删除一个大表导致其他表Opening tables
- Python 面向对象(三) 魔术方法
__getitem__ 在对实例或对象使用索引访问时调用,self[key]__dir__ 收集当前模块的信息,包括继承自其它基类(包括object类)的属性和方法 __new 定义如何创建实例__i ...
- python学习笔记 loop&&raw_input 7&& if
1.首先要说range(x) 其返回的是一个list:[0,1,2,....x-1] >>> range(5) [0,1,2,3,4] 2.Loop 共有两种形式,一种for x i ...
- 关于Springboot整合mybatis启动的问题
由于是刚pull下来的项目整体也不熟悉,然后项目无法正常启动,爆出的异常为: Invalid bound statement (not found) 这是由于创建的新模块mapper与扫描mapper ...