在Cocos2dx中使用RapidJson,它在IOS中的Accept(writer)中崩溃

在Cocos2dx中使用RapidJson,它在IOS中的Accept(writer)中崩溃,ios,cocos2d-x,rapidjson,Ios,Cocos2d X,Rapidjson,我使用cocos2dx3.9;并使用rapidjson将CCDictionary转换为字符串;我发现在真正的机器中,它会在value->Accept(wirter)中崩溃;但工作将在模拟器中进行 rapidjson::StringBuffer buffer; rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); value->Accept(writer); rapidjson::StringBuffer; rap

我使用cocos2dx3.9;并使用rapidjson将CCDictionary转换为字符串;我发现在真正的机器中,它会在value->Accept(wirter)中崩溃;但工作将在模拟器中进行

rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
value->Accept(writer);
rapidjson::StringBuffer;
rapidjson::Writer-Writer(缓冲区);
值->接受(编写器);
这是我的错误,我使用:

rapidjson::Value *value = KSCCJsonRapid::jsonValueFromDictionary(dic);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
value->Accept(writer);
std::string jsonString = buffer.GetString();
,我创建了一个新文档,并将其删除;在实际机器中,内存是有限的;因此该值无效。 可通过以下方式进行纠正:

rapidjson::Document *document = new Document();
rapidjson::Value *value = KSCCJsonRapid::jsonValueFromDictionary(dic, document);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
value->Accept(writer);
std::string jsonString = buffer.GetString();
delete value;
delete document;
rapidjson::Document*Document=new Document();
rapidjson::Value*Value=KSCCJsonRapid::jsonValueFromDictionary(dic,文档);
rapidjson::StringBuffer缓冲区;
rapidjson::Writer-Writer(缓冲区);
值->接受(编写器);
std::string jsonString=buffer.GetString();
删除值;
删除文件;
rapidjson::Document *document = new Document();
rapidjson::Value *value = KSCCJsonRapid::jsonValueFromDictionary(dic, document);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
value->Accept(writer);
std::string jsonString = buffer.GetString();
delete value;
delete document;