add Value is not contains in CFDictionary c++?
I am using the CFDictionary for maintain list.I added some key with value after added values, checking whether added keys contains in dictionary , it returns true.But if i try to get values it is return null.How to check where i missed out?
//Create Dictionary
CFMutableDictionaryRef f开发者_开发问答ileInfo = CFDictionaryCreateMutable(NULL,0,NULL,NULL);
//add Value
CFDictionaryAddValue(fileInfo, CFSTR("filename"),getstring((uint8_t*)buffer,&offset));
int size = CFDictionaryGetCount(fileInfo);
//Return 1;
if(CFDictionaryContainsKey(fileInfo,CFSTR("filename"))) // return true
{
const void* filename = CFDictionaryGetValue(fileInfo, CFSTR("filename"));
if(filename ) // return null
{
}
}
Please help me.
I think you need to pass some callbacks in when you create the dictionary otherwise the behaviour of the dictionary might not be what you expect.
Also, make sure that getstring()
does not return NULL.
精彩评论