c++ - Cocos2D X: How to check if a key exists for a plist file? -
I am using the following code to read data from my game plist:
int LevelNum = SOME_VALUE_FROM_OUTSIDE; Manmap mapfile = filesutils :: meet () - & gt; GetValueMapFromFile ("LevelDetails.plist"); Std :: string strLevel = std :: to_string (levelNum); Valuemap Map Level = Mapfile (Stellwell) .asValueMap ();
LevelDetails.plist is a plist with the dictionary as root. The problem is that there may be occasions where no name is levelNum / strLevel. So I have to check that the key exists before I run this line:
Because ValueMap is a std :: unordered_map, you can use methods of that class:
if (mapFile.count (strLevel) .count ()> gt; {Manmap Maps = mapfile.tr (strLevel) .asValueMap (); }
The Valmax announcement in Cocos 2D X is:
typedef std :: unordered_map & lt; Std :: string, value & gt; ValueMap;
Comments
Post a Comment