First, a string type data
Ccuserdefault::shareduserdefault ()->setstringforkey ("Jason", "Hello") is stored;
Ccuserdefault::shareduserdefault ()->flush ();
Then get
the string const char* FileName = Ccuserdefault::shareduserdefault ()->getstringforkey ("Jason") by the following way. C_STR () ;
The print statement is normal and the output is Hello
cclog ("filename:%s", fileName);
But the following statement appears on the device on the error, or nothing, or the string is incomplete, or display Helvetica
cclabelttf* label = cclabelttf::create (FileName, "Helvetica", );
Label->setposition (CCP ());
AddChild (label);
Then to solve the above problem, we change the way
cclabelttf* label = Cclabelttf::create (Ccuserdefault::shareduserdefault () Getstringforkey ("Jason"). C_str (), "Helvetica", "(");
Label->setposition (CCP ());
AddChild (label); The result is Hello, normal
Let's put it another way
std::string fileName = Ccuserdefault::shareduserdefault ()->getstringforkey ("Jason");
cclabelttf* label = Cclabelttf::create (Filename.c_str (), "Helvetica", +);
Label->setposition (CCP (240, 160)); The results are also Hello, normal
Another way to do it
std::string fileName = Ccuserdefault::shareduserdefault ()->getstringforkey ("Jason");
Const char* file = Filename.c_str ();
cclabelttf* label = cclabelttf::create (file, "Helvetica",);
Label->setposition (CCP ());
AddChild (label);
As a result, the writing is also normal, then why the most up-to-do not get the correct results?
Summary: Although the underlying reasons do not know, but you can first remember: return std::string type is used std::string type to connect
My cocpos2d-x version cocos2d-2.1rc0-x-2.1.2, there are children's shoes to know why please enlighten.