首页 > 代码库 > cocos2d-x3.0 用CCDictionary写文件

cocos2d-x3.0 用CCDictionary写文件


bool CDownLoad_LocalData::WriteToConfigFile( DownLoadLocalData* downdata ){

CCDictionary* pDict = CCDictionary::create(); 
unsigned int lessonid = downdata->lession_id;
char s_lessonid[10];
sprintf(s_lessonid,"%d",lessonid);


CCString* pValue1 = CCString::create(s_lessonid);
CCString* pValue2 = CCString::create(downdata->fileLocal_path);  
CCString* pValue3 = CCString::create(downdata->downUrl);  
pDict->setObject(pValue1, "lessonid");  
pDict->setObject(pValue2, "fileLocal_path");  
pDict->setObject(pValue3, "downUrl"); 


m_total_dict->setObject(pDict,pValue1->getCString());


if(m_total_dict->writeToFile(m_fileapth.c_str()))//m_fileapth为写文件的路径
CCLog("Write to file success!");
return true;
}