CCDictionary - Saving different object types



I’m using Cocos2dx 2.2.2, and I don’t find a way to save values other then CCString using a CCDictionary.
I will also need to save a CCarray with integers, do I need to convert all to CCString?

Here is my code

void GameStatus::saveGame()
	CCDictionary * myDictionary = new CCDictionary();

	CCString testValue1 ="ABC";
	CCInteger testValue2 = 5;	
	myDictionary->setObject( &testValue2,"test_key2" );
	CCFloat testValue3 = 2.5f;	
	myDictionary->setObject( &testValue3,"test_key3" );
	CCBool testValue4 = false;
	myDictionary->setObject( &testValue4,"test_key4" );

	std::string _path = CCFileUtils::sharedFileUtils()->getWritablePath();
	_path.append ("GameData.plist");

	if( myDictionary->writeToFile(_path.c_str()))
		CCLOG("Written falied");


Saved File Contents

<?xml version="1.0" encoding="UTF-8"?> test_key1 ABC test_key2 test_key3 test_key4




cocos2d-x 2.2.2 don’t support store other types except for CCString.

But the issue has been fixed in the v3.0 rc0 version. You could refer to the develop branch and modify the source code to support your own needs.