plist is belong to the iPhone but how to use in cocos2d-android game Engine ?
Is this possible or not ??
plist is belong to the iPhone but how to use in cocos2d-android game Engine ?
Is this possible or not ??
plist Files are 'property list' files. They handle Foundation common collections / types : NSDictionary, NSArray, NSString, NSNumber, NSDate, NSData.
Whenever you need some configuration file, some list of values, or of keys->values : plist is the preferred way (plist is either an array or a dictionary)
Foundation classes implement NSCoding
protocol, so it's super-easy to unserialize :
+arrayWithContentsOfFile:
+dictionaryWithContentsOfFile:
methods.and the other way, serializing :
writeToFile:atomically:
Plist is way to store a structure , data, object and any other information that is required to store in device permanently. In iPhone it is mostly used as alternative of Sqlite database. In iOS there is info.plist default file in each Xcode project it contains the project settings like Bundle ID, Supported orientation and many more elements. We can create Our own Plist e.g User.plist that will store the users name and passwords etc. In Cocos2D plists are used for game settings, levels, scores saving purposes. here is an example how to get data from plist saved in Resources.
NSString *path = [[NSBundle mainBundle] bundlePath]; NSString *dataPath = [path stringByAppendingPathComponent:@"GameData.plist"];
NSDictionary *infoDict = [[NSDictionary dictionaryWithContentsOfFile:dataPath]retain];
plist and nsDictionary are same, if i am not wrong then NSDictionary is the replacement of plist.
so use NsDictionary, life time of both is same, but reading of plist and writing in plist is time taking rather then NSDictionary.