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文件的更多相关文章

  1. 回忆基础:制作plist文件

    -(void)creatPlistFileWithArr:(NSArray *)array{ //将字典保存到document文件->获取appdocument路径 NSString *docP ...

  2. 还原TexturePacker plist 文件以及图片的方法 (切开各小图片)

    原地址:http://blog.csdn.net/linuxchen/article/details/16865645 Python 脚本:(来自网络) unpack_plist.py 命令行: py ...

  3. 3种方法快速制作tpk文件 [转]

    tpk是ArcGIS10.1推出的一种新的数据文件类型,主要是用于将切片文件打包形成离线地图包,tpk可以在ArcGIS Runtime或者ArcGIS for Android/iOS中作为切片底图被 ...

  4. plist文件、NSUserDefault 对文件进行存储的类、json格式解析

    ========================== 文件操作 ========================== Δ一 .plist文件 .plist文件是一个属性字典数组的一个文件: .plis ...

  5. ios开发之Info.plist文件相关配置

    前言:在iOS开发中有些情况下需要对Info.plist文件进行配置,以下介绍几种相关配置.以后遇到需要配置的再更新... 开发环境:swift3.0.1,Xcode8.1 一,项目中需要使用第三方字 ...

  6. Excel文件转plist文件出现的文件编码问题

    今天在测试时遇到了需要将大量整理好的Excel数据转换为plist文件的情况.百度了一下教程,发现虽然别人也遇到过类似的情况,但是有些讲的还是不够细致.所以做如下整理.   百度到的内容中有使用Mes ...

  7. IOS学习笔记之获取Plist文件读取数据

    @property(nonatomic,strong) NSArray *pic; //创建数组属性 @property(nonatomic,assign) int index; //创建索引属性 @ ...

  8. NSIS使用教程(安装包制作安装文件教程,如何封装打包文件) 中文版

    nsis中文版(Nullsoft Scriptable Install System)是一个专业的开源的可以用来封闭Windows程序的实用工具,是一个开源的 Windows 系统下安装程序制作程序. ...

  9. iOS开发——UI基础-懒加载,plist文件,字典转模型,自定义view

    一.懒加载 只有使用到了商品数组才会创建数组 保证数组只会被创建一次 只要能够保证数组在使用时才创建, 并且只会创建一次, 那么我们就称之为懒加载 lazy - (void)viewDidLoad 控 ...

随机推荐

  1. Android 开发笔记___SD卡文件操作

    package com.example.alimjan.hello_world.Utils; import android.graphics.Bitmap; import android.graphi ...

  2. javascript 备忘 细节 相关

    DOMContentLoaded事件触发时机,即dom tree完成但页面未必渲染完毕.   var a = [1,2,3,4]; var length = a.length; alert((leng ...

  3. 用Nodejs+Express搭建web,nodejs路由和Ajax传数据并返回状态,nodejs+mysql通过ajax获取数据并写入数据库

    小编自学Nodejs,看了好多文章发现都不全,而且好多都是一模一样的 当然了,这只是基础的demo,经供参考,但是相信也会有收获 今天的内容是用Nodejs+Express搭建基本的web,然后呢no ...

  4. sql select case when 语句

    有道笔试题: 服务器监控表server_status中,当服务器状态发生server_status变化时数据表中将被插入一条记录,状态0表示停机  1表示正常,用SQL查询Server A 的停机开始 ...

  5. 机器学习数学|微积分梯度jensen不等式

    机器学习中的数学 觉得有用的话,欢迎一起讨论相互学习~Follow Me 原创文章,如需转载请保留出处 本博客为七月在线邹博老师机器学习数学课程学习笔记 索引 微积分,梯度和Jensen不等式 Tay ...

  6. spring返回@ResponseBody报406

    HTTP Status 406 - type Status report message description The resource identified by this request is  ...

  7. java Log4j日志配置详解大全

    一.Log4j简介 Log4j有三个主要的组件:Loggers(记录器),Appenders (输出源)和Layouts(布局).这里可简单理解为日志类别,日志要输出的地方和日志以何种形式输出.综合使 ...

  8. 清理win10过期补丁的命令

    作用是删除已经被新版本取代的旧系统文件 DISM.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase 注1: 执行后, 补丁就无法 ...

  9. linux学习笔记二

    进程(process)是程序实体运行的过程,是系统进行资源分配和调度的独立单位,或者说是一个程序在处理机上的一次执行活动. 区分一下进程和程序 1.0 程序是一个静态指令的集合:而进程是一个程序的动态 ...

  10. HTML基础--position 绝对定位 相对定位 锚点链接

    position 定位属性,检索对象的定位方式 一.语法:position:static /absolute/relative/fixed 取值: 1.static:默认值,无特殊定位,对象遵循HTM ...