How to use UserDefault::getInstance()->setDataForKey

What is the point of cocos2d::Data? What would it be used for and how would it be used?

Okay never mind. Sorry, I found the sample code and now I understand how to use it, but for those of you who can’t find it, here’s some sample code:

template<typename T>
void setData(const char* key)
{
Data data;
vector<T> v;
for (int i = 0; i <= 5; i++)
{
    v.push_back(static_cast<T>(i));
}
data.copy((unsigned char*) v.data(), v.size() * sizeof(T));
UserDefault::getInstance()->setDataForKey(key, data);
}
3 Likes