属性列表数据持久化
1.使用_Dictionary读写属性列表文件
//创建字典元素
{
auto dict = __Dictionary::create();
dict->setObject(String::create("2008-08-16 10:01:01"), "date");
dict->setObject(String::create("初始化数据。"), "content");
}
//获得写入目录
string writablePath = FileUtils::getInstance()->getWritablePath();
//写入,成功返回true
root->writeToFile(fullPath.c_str())
//读取并创建字典对象
auto root = __Dictionary::createWithContentsOfFile(fullPath.c_str());
//从字典中取出列表对象,需要强制转换类型,并插入新元素
{
auto dict = __Dictionary::create();
dict->setObject(String::create(currentTime), "date");
dict->setObject(String::create("欢迎使用MyNote。"), "content");
auto arry = static_cast<__Array*>(root->objectForKey("root"));
arry->addObject(dict);
}
//删除最后一个元素对象
arry->removeLastObject();
//读取列表,并显示其中的字典元素内容
{
//循