我也不太专业,主要做个记录
1 把.plist文件放在Resources文件中读取
FileUtils *fu = FileUtils::getInstance();
auto vm = fu->getValueMapFromFile("Chinese.plist"); //
info_win = vm["win"].asString().c_str();
2 获取.plist文件的相对路径,把相对路径转化成绝对路径
//获取Chinese.plist的相对路径
std::string testPlistPath = "images\\Chinese.plist";
//获取Chinese.plist的绝对路径
std::string f1 = FileUtils::getInstance()->fullPathFromRelativeFile(
"Chinese.plist", testPlistPath);
//判断路径文件是否存在
if (FileUtils::getInstance()->isFileExist(f1)) {
auto lo = __Dictionary::createWithContentsOfFile(f1.c_str());
auto che = (__Dictionary *) lo->objectForKey("chess");
auto a = (__Dictionary *) che->objectForKey("1");
auto intValue = (__String *) a->objectForKey("x4");
x14 = intValue->intValue();
}
3 读取安卓手机中的.plist文件
//获取安卓手机中文件路径
std::string writablePath = FileUtils::getInstance()->getWritablePath();
std::string fullPath = writablePath + "te.plist";
//判断路径文件是否存在
if (FileUtils::getInstance()->isFileExist(fullPath)) {
//读取文件的内容
auto loadDict = __Dictionary::createWithContentsOfFile(
fullPath.c_str());
auto intValue = (__String *) loadDict->objectForKey("integer");
//转化int值
int int_temp = intValue->intValue();
//创建写入.plist文件
auto root = Dictionary::create();
auto intObject = Integer::create(inRou);
root->setObject(intObject, "integer");
if (root->writeToFile(fullPath.c_str())) {
}
}