From fc655162fa7d185bec408740c16fbd0ab3cf9091 Mon Sep 17 00:00:00 2001 From: luocker Date: Fri, 27 Dec 2013 00:26:02 +0800 Subject: [PATCH] Update CCString.cpp we can't change _string value after get Array. --- cocos/base/CCString.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos/base/CCString.cpp b/cocos/base/CCString.cpp index 9e0f4b314f..a8643372a0 100644 --- a/cocos/base/CCString.cpp +++ b/cocos/base/CCString.cpp @@ -181,20 +181,20 @@ void __String::appendWithFormat(const char* format, ...) __Array* __String::componentsSeparatedByString(const char *delimiter) { __Array* result = __Array::create(); - + std::string strTmp = _string; size_t cutAt; - while( (cutAt = _string.find_first_of(delimiter)) != _string.npos ) + while( (cutAt = strTmp.find_first_of(delimiter)) != strTmp.npos ) { if(cutAt > 0) { - result->addObject(__String::create(_string.substr(0, cutAt))); + result->addObject(__String::create(strTmp.substr(0, cutAt))); } - _string = _string.substr(cutAt + 1); + strTmp = strTmp.substr(cutAt + 1); } - if(_string.length() > 0) + if(strTmp.length() > 0) { - result->addObject(__String::create(_string)); + result->addObject(__String::create(strTmp)); } return result;