-2

plist is belong to the iPhone but how to use in cocos2d-android game Engine ?

Is this possible or not ??

Akarsh M
  • 1,629
  • 2
  • 24
  • 47

3 Answers3

2

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 :

  • using NSArray's +arrayWithContentsOfFile:
  • or NSDictionary 's +dictionaryWithContentsOfFile: methods.

and the other way, serializing :

  • writeToFile:atomically:
Vinzzz
  • 11,746
  • 5
  • 36
  • 42
  • the things which is handle through this plist . If i dont want to use plist file the what should i do for working like plist ??? – Akarsh M Feb 27 '13 at 10:45
  • I don't understand what you're trying to achieve... If you're only into 'serializing' an object into a file - and vice-versa - You might look into `NSCoding` protocol. (which can use whatever file extension you please) – Vinzzz Feb 27 '13 at 10:48
  • please have a look on the question and their comment .. you can easily understand what I want to know ?? – Akarsh M Feb 27 '13 at 10:56
  • Okay... No, I don't easily understand what you want to know. I've never used Cocos2d, so I don't know what plists they have, and how they use it. However, each iOS application needs a `whateverPrefix_info.plist` (http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html), so THIS plist cannot be removed from application... – Vinzzz Feb 27 '13 at 11:39
  • You mean 'building' the application manually, without XCode ? You can use the command-line `xcodebuild`. But you'll still need the `info.plist`, it's used at runtime by system to gather informations about application (should it run in background, can it open documents from other applications, what icons it has on iOS start-screen, etc...) – Vinzzz Feb 27 '13 at 12:40
1

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];

waseem
  • 21
  • 1
  • the things which is handle through this plist . If i dont want to use plist file the what should i do for working like plist ??? – Akarsh M Feb 27 '13 at 10:45
-1

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.

aBilal17
  • 2,974
  • 2
  • 17
  • 23