Skip to content

Instantly share code, notes, and snippets.

@iburlakov
Created September 27, 2012 19:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iburlakov/3795877 to your computer and use it in GitHub Desktop.
Save iburlakov/3795877 to your computer and use it in GitHub Desktop.
Using of CFDictionaryGetValueIfPresent
CFDictionaryRef dict;
/*
Get some dictionary...
*/
SInt32 intVal = 0;
CFNumberRef cfIntVal;
char* strVal;
CFStringRef cfStrVal;
if(CFDictionaryGetValueIfPresent(dict, CFSTR("SomeKey0"), &cfIntVal) &&
CFDictionaryGetValueIfPresent(dict, CFSTR("SomeKey1"), &cfStrVal)
{
CFNumberGetValue(cfIntVal, kCFNumberSInt32Type, &intVal);
CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
strVal = CFStringGetCStringPtr(cfStrVal, encodingMethod);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment