Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

adriweb

macrumors newbie
Original poster
Oct 23, 2010
13
1
France
Hello,

I' ve been looking around, for quite a while now, for a way to edit a specific object in a multi-level .plist file. And I couldn't find anything anywhere...

So, basically , here's the structure of the plist file :

9aXEa.jpg



I thought of saving dictionaries as a an object (for each sublevel) but it didn't work really well (maybe I didn't do it correctly...) as it erased the other things ... :/


And you can see on the image the value I want to change...

Any ideas/advices appreciated !

Thanks for the help !


Adrien
 
Last edited:
IMO, editing plists like this is no fun. Instead I write some code that builds the plist from some other kind of data structure like an array of structs and writes it out. I run this code on the Sim and move the plist file in the Finder to the Resources folder manually.

This way editing the plist file is just a matter of editing some text, rather than opening up the plist editor, which is painful for complicated plist files, or making more than a few changes.

There also are some plist editors that can be run from the command line or from a script that you might prefer.
 
Oh, it's not that I'm building a program to help me edit .plist files, what I need to do is actually editing the .plist in my iOS app because my application is built around this database, and the object I want to edit is one of the value that I need for some feature I want to build :)

Thanks for replying though !


PS :

this is the application I'm talking about :
http://itunes.apple.com/us/app/isen-colles-n1a/id412495736?mt=8&ls=1
 
You want to modify the plist in response to user action or you want to edit to provide it as an update to the one that's in the app?

In the first case you just need to use mutable containers. Replace or add or delete any of the content and write it out.

In the second case my answer from earlier applies.
 
IMO, editing plists like this is no fun. Instead I write some code that builds the plist from some other kind of data structure like an array of structs and writes it out. I run this code on the Sim and move the plist file in the Finder to the Resources folder manually.

This way editing the plist file is just a matter of editing some text, rather than opening up the plist editor, which is painful for complicated plist files, or making more than a few changes.

There also are some plist editors that can be run from the command line or from a script that you might prefer.

The plutil command is very handy for converting between plists and XML files.

(Yes, I know this is not what the original poster asked for.)
 
You want to modify the plist in response to user action or you want to edit to provide it as an update to the one that's in the app?

In the first case you just need to use mutable containers. Replace or add or delete any of the content and write it out.

First Case, yep. It would be from a user filling a text field.

So, how do I use mutable containers with what I already have ?

(Actually, I already have some code to change the "most-inner" (as of the .plist structure) dictionary, but I don't know how to save that dictionary back into the sub-dictionary of the sub-array of the sub-dictionary of the sub-array ...)

I mean, would I have to change the whole structure and not use .plist anymore ?
Then I'd rather move to SQLite ;)

Thanks for your answer.


PS : the plist is mutable (and all dicts are)
 
First, it's quite possible that sqlite or core data would be simpler for this. I guess it depends on the size and complexity of the data.

If your containers are already mutable then its just a matter of using addObject, setObject:forkey:, replaceObjectAtIndex: and other methods for changing your data. Then you have to write out the plist.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.