本文整理汇总了C++中UserDefault::setStringForKey方法的典型用法代码示例。如果您正苦于以下问题:C++ UserDefault::setStringForKey方法的具体用法?C++ UserDefault::setStringForKey怎么用?C++ UserDefault::setStringForKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserDefault
的用法示例。
在下文中一共展示了UserDefault::setStringForKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNetBiosMacAddresses
const std::string CCNative::getDeviceID(void)
{
#define UDID_KEY "__UDID_KEY__"
std::string udid;
UserDefault* userDefault = UserDefault::getInstance();
if( NULL != userDefault )
{
udid = userDefault->getStringForKey( UDID_KEY );
}
if( udid.size() == 0 )
{
//GUID uuid;
//CoCreateGuid(&uuid);
//// Spit the address out
//char mac_addr[18];
//sprintf(mac_addr,"%02X:%02X:%02X:%02X:%02X:%02X",
//uuid.Data4[2],uuid.Data4[3],uuid.Data4[4],
//uuid.Data4[5],uuid.Data4[6],uuid.Data4[7]);
udid = GetNetBiosMacAddresses();
if( userDefault )
{
userDefault->setStringForKey(UDID_KEY, udid);
userDefault->flush();
}
}
return udid;
}
示例2:
NS_CC_EXTRA_BEGIN
const std::string CCNative::getDeviceID(void)
{
#define UDID_KEY "__UDID_KEY__"
std::string udid;
UserDefault* userDefault = UserDefault::getInstance();
if( NULL != userDefault )
{
udid = userDefault->getStringForKey( UDID_KEY );
}
if( udid.size() == 0 )
{
//GUID guid = {0};
//char szGuid[128]={0};
//CoCreateGuid(&guid);
//sprintf(szGuid, "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
//udid = "aaaaaaaaaaaaaaaaaaaa";
udid = Application::getInstance()->getMacAddress();
/// xx:xx:xx:xx:xx
///一共有16位
///4个冒号
std::string::iterator end_pos = std::remove(udid.begin(), udid.end(), ' ');
udid.erase(end_pos, udid.end());
if( userDefault && udid.size() >= 16 )
{
userDefault->setStringForKey(UDID_KEY, udid);
}
}
return udid;
}
示例3: onHttpRequestCompleted
//Callback
void TrivialAPI::onHttpRequestCompleted(HttpClient* client, HttpResponse* response)
{
const char *responseTag;
if (!response)
return;
if (!response->isSucceed())
{
log("response failed");
log("error buffer: %s", response->getErrorBuffer());
log("HTTP Status Code: %ld", response->getResponseCode());
std::vector<char> *buffer = response->getResponseData();
printf("Http Test, dump data: ");
for (unsigned int i = 0; i < buffer->size(); i++)
{
printf("%c", (*buffer)[i]);
}
printf("\n");
UserDefault *pUserDefaults = UserDefault::getInstance();
std::string hash = pUserDefaults->getStringForKey("hash");
if (hash.length() == 0) {
MessageBox("Interneta beharrezkoa da", "Error");
} else {
_finishCalbback->execute();
}
} else {
responseTag = response->getHttpRequest()->getTag();
int statusCode = (int) response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, responseTag);
//log(statusString);
}
std::vector<char> *buffer = response->getResponseData();
std::string str(buffer->begin(), buffer->end());
if (!strcmp(responseTag, "generalToken")) {
UserDefault *pUserDefault = UserDefault::getInstance();
std::string savedHash = pUserDefault->getStringForKey("hash");
std::string token = parseGeneralToken(str);
if (savedHash.compare(token) != 0) {
_hash = token;
_sqlHelper->resetDB();
updateKategoriak(emptyPrivateCode);
} else {
//updatePrivateData();
_finishCalbback->execute();
}
} else if(!strcmp(responseTag, "kategoriak")) {
parseKategoriak(str);
updateMultzoak(emptyPrivateCode);
} else if(!strcmp(responseTag, "multzoak")) {
parseMultzoak(str);
updateGalderak(emptyPrivateCode);
} else if(!strcmp(responseTag, "galderak")) {
parseGalderak(str);
UserDefault *pUserDefault = UserDefault::getInstance();
std::string savedHash = pUserDefault->getStringForKey("hash");
if (savedHash.empty()) {
_sqlHelper->initUserData();
} else {
_sqlHelper->updateUserData();
}
pUserDefault->setStringForKey("hash", _hash);
pUserDefault->flush();
//updatePrivateData();
_finishCalbback->execute();
}
}