plist

Read binary plist into NSDictionary

旧时模样 提交于 2019-11-29 12:13:41
Is there simple way to parse the binary plist file into the NSDictionary representation? I am searching something like that: NSString* strings = [NSString stringWithContentsOfURL: ... encoding: NSUnicodeStringEncoding error: ...]; NSMutableDictionary* pairs = (NSMutableDictionary*)[strings propertyListFromStringsFileFormat]; Using this code caused the exception while parsing the binary plist file. Are you looking for [NSDictionary dictionaryWithContentsOfFile:] ? Considering a file called DataStorageFile.plist , you can use: NSString *dataPath = [[NSBundle mainBundle] pathForResource:@

NSDictionary value replacing instead of adding in Plist

孤人 提交于 2019-11-29 12:12:05
hi i tried to add values(book id,page number,notes) from NSdictionary to Plist but each time the new value replacing the previous one?but i need all values in plist my code for adding dictionary to plist is NSString *bid=@"95"; NSString *pnum=@"12"; userNotes=[[NSMutableDictionary alloc]init]; [userNotes setValue:userNotesTextview.text forKey:@"notes"]; [userNotes setValue:bid forKey:@"bookid"]; [userNotes setValue:pnum forKey:@"pagenumber"]; userNotesView.hidden=YES; _background.hidden = YES; userNotesTextview.text=@""; [self savingMetaData]; NSMutableArray *notes=[[NSMutableArray alloc]init]

Appending data to PLIST - iPhone

拜拜、爱过 提交于 2019-11-29 11:56:55
we need to be able to read in the contents of an existing plist file then add to the array / dictionary then write this new data to the plist file. The stricture is simple. We want multiple root keys as arrays and each with a few values. The structure looks like this, 124818240124810284.JPG Array item 0 String Some Attribute 1 item 1 String Some Attribute 2 So far we can create the above with no issue. But, as soon as we go to write another array to the plist the file is simply overwritten and all current contents are lost. What we need to do is read in the above and add to it so we get

how to write NSMutableDictionary into Plist

心不动则不痛 提交于 2019-11-29 11:53:51
can any one help me with this how to write a NSMutableDictionary into a plist.... thanks in advance.. Make sure the pList file you are writing to is located in a legal place to edit it, for example Documents in the apps sandbox. Then find the path to that location (if there is an existing pList file, it will overwrite), and use: [myDictionary writeToFile:path atomically:YES]; Write how far you are in the process, and maybe some code / error-message... [yourDict writeToFile:filePath atomically:YES]; Note that dictionary must contain plist objects (instances of NSData , NSDate , NSNumber ,

How to parse .plist file in Java?

ⅰ亾dé卋堺 提交于 2019-11-29 11:26:44
I am trying to parse a .plist file in Java but not understanding how. I used a DOM parser but it gives an error and is not able to read .plist file. This is my plist file: xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>All Samples</key> <array> <dict> <key>Message</key> <string>1) UIATarget </string> <key>Timestamp</key> <date>2011-07-06T19:40:09Z</date> <key>Type</key> <integer>0</integer> </dict> This my main function: public static void main(String[] args) throws

NSNumber vs Int

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 10:00:52
If integers cannot be written to a dictionary and then to a .plist, but NSNumbers can is it better to use NSNumbers throughout the app, rather than needing to convert every-time saving or loading a dictionary from a .plist? As a generalization: Just stick with POD types until you need to use an object based representation, such as NSNumber . The performance is much better with the PODs, but you'll need NSNumber in some cases. In some cases, it may make sense to use NSNumber instead -- this is typically when you reuse a NSNumber often -- this is to avoid making a ton of duplicate NSNumber s.

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

旧街凉风 提交于 2019-11-29 09:26:01
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. 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 a binary one). Once the root object is an array, Xcode seems to keep it that way and when you select to add

Localizable.strings causing plist parsing error

爱⌒轻易说出口 提交于 2019-11-29 09:19:03
I have just localized the file Localizable.strings in my Xcode project in order to localise my application to a few different languages. However, having edited each of the files in the standard "key = value" format, I receive the following parsing error, which does not specify a file making it hard to track down what it is referring to. CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 10. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug. I have looked through each of the *.strings files, specifically on line 10, and

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

倾然丶 夕夏残阳落幕 提交于 2019-11-29 08:55:57
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. NSUserDefaults is a plist (that is why only plist types can be stored in it). So ultimately there isn't going to be much difference in efficiency (whatever you mean by that). Your consideration should rather be where it is

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

五迷三道 提交于 2019-11-29 08:21:20
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, like Apple's info.list behaves. Normally my plists will display in the editor with 3 columns. Key, Type