I’m trying to make life a little bit easier for me. I get a lot of values from NSDictionary, like this:
//First, make sure the object exist
if ([myDict objectForKey: @"value"])
{
NSString *string = [myDict objectForKey: @"value"];
//Maybe do other things with the string here...
}
I have a file (Variables.h) where I store a lot of stuff to control the app. If would be nice to put a few helper methods in there. So instead of doing the above code, I would like to have a c++ function in the Variables.h, so I can just do this:
NSString *string = GetDictValue(myDictionary, @"value");
How do you write that c++ method?
Thanks in advance
I suppose this is technically a c function, is c++ a strict requirement
Consider using
idand casting where necessary: