CCArray *myArray = CCArray::createWithCapacity(3); myArray->addObject(CCInteger::create(2)); myArray->addObject(CCInteger::create(4)); myArray->addObject(CCInteger::create(6)); CCObject *obj = myArray->objectAtIndex(1); // obj points to the element at index 1 (4)
CCArray *myArray = CCArray::createWithCapacity(2); myArray->addObject(CCString::create("hello")); myArray->addObject(CCString::create("world")); CCString *str = (CCString*) myArray->objectAtIndex(0); // str points to "hello"In this example, we create another CCArray object and add two CCString objects to it. We then retrieve the first element of the array (index 0) using objectAtIndex and cast the result as a CCString pointer. The package library for CCArray is "cocos2d".