How to add a int value into a CCArray;

When you met some status that there is a set of int value which need to be managed.
How do you organize you code of cocos2d-x.
Thanks.

maybe, vector, C array, something else?

See attached “IntVal.h”. Its a simple CCObject class with an int parameter.

Then simply create one and add it to your CCArray, something like this:-

CIntVal *pI = new CIntVal(); 
MyArray->addObject( (CCObject*)pI );

A lot of code to simply add an int value to an array eh!?

I have no idea, what need you have to add int into CCArray.

Using vector is enough, C++ is not another one .NET to store int in class-style =)

Prefer std::vector, but if you need CCArray - use CCString::createWithFormat("%i", value) or CCInteger. Note that CCArray is very dangerous for bad code: any stored value is CCObject, but there is no garantue that no one programmer added CCImage* or MyClass* instance to array. You can use dynamic_cast or CCDataVisitor (read also about Visitor pattern) for heterogenious arrays.