An unimaginable Problem with CCUserDefault.


#1

Hello everyone.
Yesterday i was confused by an unreasonable bug:

I can’t read the string stored in the “UserDefault.xml” file.

Here is my example code:
@
std::string todayString = “2013_4”;
CCUserDefault::sharedUserDefault()->setStringForKey(todayString.c_str(),“SomeString”);

std::string todayMessage = CCUserDefault::sharedUserDefault()->getStringForKey(todayString.c_str(),“NULL”);

if(todayMessage != “NULL”)
CCLog(“Got it!”);
else
CCLog(“Can’t read from file”);

//Output:
//Can’t read from file
@

But i noticed that if change my string’s name(which consists of all-number before),it can be detected normally.

@
std::string todayString = “Day_2013_4”;

//…
/*Other lines have not changed./

//Output:
//Got it.
@

It’s a good news for me to solve this bug.
But i really want to know the reason.

Thanks.