1、// __Array使用
//Ref类:控制对象的引用计数,retain、release、autorelease
auto str1=__String::create("String1");
auto str2=__String::create("String2");
auto str3=__String::create("String3");
auto str4=__String::create("String4");
auto str5=__String::create("String5");
auto array=__Array::create();
array->addObject(str1);
array->addObject(str2);
array->addObject(str3);
array->addObject(str4);
array->addObject(str5);
array->removeLastObject();
array->insertObject(str5, 2);
for (int i=0; i<array->count(); i++) {
auto str=(__String *)array->getObjectAtIndex(i);
log("str:%s",str->getCString());
}
2、__Dictionary使用
auto pDic=__Dictionary::create();
auto pValue1=__String::create("Hello");
auto pValue2=__String::create("World");
auto pValue3=__Integer::create(300);
pDic->setObject(pValue1, "key1");
pDic->setObject(pValue2, "key2");
pDic->setObject(pValue3, "key3");
auto pStr1=(__String *)pDic->objectForKey("key1");
log("key1:%s",pStr1->getCString());
auto pStr2=(__String *)pDic->objectForKey("key2");
log("key2:%s",pStr2->getCString());
auto pInteger=(__Integer *)pDic->objectForKey("key3");
log("key3:%d",pInteger->getValue());