plist

How do you change a plist's root object type to NSArray in Xcode 4

折月煮酒 提交于 2019-11-28 02:53:02
问题 how do you change the root object type to an NSArray in a plist created in Xcode 4? It defaults to a type of NSDictionary, but I can't find a way to change it. 回答1: You cannot do that in Xcode4. What you can do is either create a plist by hand with an array as root object or take an existing one (of course this one should be an empty one, since converting one with rows makes no sense) and modify it by replacing <dict/> with <array/> (you may have to first convert it to an XML plist, if it is

Command-line tool for converting PLIST to JSON?

半世苍凉 提交于 2019-11-28 02:49:06
Is there a command line tool available for converting .plist files to JSON? If not, what would be the approach for creating one using Objective-C or C on a Mac? For instance, there is JSONKit, for Objective-C. How would one go about opening a .plist file, pass it to JSONKit, and serialize that as JSON? If you are on a Mac you can use the plutil tool on the command line (this comes with the developer tools I believe): plutil -convert json Data.plist as mentioned in the comments, this will overwrite the existing data. To output to a new file plutil -convert json -o Data.json Data.plist The

modifying a plist is not working

╄→гoц情女王★ 提交于 2019-11-28 02:22:43
i have to modify a BOOL value in my plist file stored with the bundle.i am able to access the dictionary which i have to modify .from nslogging i can see that dict is updated with the new value ,but the problem is when i check the plist in bundle it is not being modified.any clue on why it is not updating the plist NSString* plistPath = nil; NSFileManager* manager = [NSFileManager defaultManager]; if (plistPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"TopicsList.plist"]) { if ([manager isWritableFileAtPath:plistPath]) { NSMutableArray* dictarrays = [NSMutableArray

Is a plist or NSUserDefaults More Efficient for storing a small amount of data?

冷暖自知 提交于 2019-11-28 02:08:40
问题 I can go either way on this for this project, but I'm curious if using a plist to store some data is going to be more or less efficient than just keeping a plist in the documents folder. The data is about 50 strings/dictionaries. In both cases the data gets persisted using some file IO so disk access should be similar. However, the plist seems like a little more work. 回答1: NSUserDefaults is a plist (that is why only plist types can be stored in it). So ultimately there isn't going to be much

How does Apple make the info.plist display its “Information Property List”?

穿精又带淫゛_ 提交于 2019-11-28 01:52:33
问题 My plists simply start with "Root". Theirs contains arrays of useful stuff you can select to tweak the configuration. The specific info.plist I am looking at is in an iphone project. I have researched this a little bit, (not alot) but haven't even detected a smell of solution. What mechanism is putting this together? Can I bend it to my will? To clarify, I am not referring to simply editing the plist, but using the Property List Editor to define the drop down lists in the left hand column,

How do I load a plist file from disk as a NSDictionary on iOS?

三世轮回 提交于 2019-11-27 23:36:01
I want to load the plist file from disk (documents, application cache, ...) not from a resource bundle. You can load a plist from any accessible file path with -initWithContentsOfFile: or +dictionaryWithContentsOfFile: Load a plist from a file, and create the file if it did not exist: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); self.plistFile = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"example.plist"]; self.plist = [[NSMutableDictionary alloc] initWithContentsOfFile:plistFile]; if (!plist) { self.plist = [NSMutableDictionary

Using PLists for Persistence on iPhone

試著忘記壹切 提交于 2019-11-27 22:49:16
问题 Simple question about property lists within an iphone app. I know you can read data in from a plist, but is there a way to write user-inputted data to a plist? If so, how? It's easy to find tutorials on reading information from plists, but I'm having trouble finding resources on writing to plists. 回答1: This is how I write data items to a plist: [myPlistFile setInteger: myInt forKey: @"someKey"]; Of course, you can change setInteger with setBool, etc for different types. Hope this helps! --

What's the difference between a dictionary and an array?

混江龙づ霸主 提交于 2019-11-27 21:00:11
问题 What is the difference between a dictionary and an array, especially when working with PLIST files? What are the advantages of using one over the other? Thanks! 回答1: Both NSDictionary and NSArray are collection classes, i.e. the group together other objects. An NSArray is an 'ordered collection' - every item in the collection has an integer index, so there is an explicit order to the items. If you swap the order of items in the collection then the collection is no longer the 'same' as the

Setting up a plist to store application data (not settings) for an iPhone game

99封情书 提交于 2019-11-27 20:56:54
I am writing an iPhone game and have it working well with my level data hard coded but I would like to store the level data in a plist a load it at launch. I have never used plists and am having trouble understanding how I should set the plist up based on my data model. Here is how I have it hard coded now: (in my appDelegate) - (void)loadLevels { //setup NSNumber objects to load into sequences NSNumber * rID = [[[NSNumber alloc] initWithInt:0] autorelease]; NSNumber * bID = [[[NSNumber alloc] initWithInt:1] autorelease]; NSNumber * gID = [[[NSNumber alloc] initWithInt:2] autorelease];

NSString: newline escape in plist

南笙酒味 提交于 2019-11-27 18:28:21
I'm writing a property list to be in the resources bundle of my application. An NSString object in the plist needs to have line-breaks in it. I tried \n , but that doesn't work. What do I do to have newlines in my string in the plist? Thanks. If you're editing the plist in Xcode's inbuild plist editor, you can press option-return to enter a line break within a string value. I found a simpler solution: NSString *newString = [oldString stringByReplacingOccurrencesOfString:@"\\n" withString:@"\n"]; It seems the string reader escapes all characters that need to be escaped such that the text from