defaults write -array
Imported from the Apple Support Forums via the Wayback Machine 🔗
hello,
i'm having some trouble writing a complex array using defaults. here is an example you can try to see what i'm referring to:
defaults read com.apple.dock persistent-apps
i just used this example because i think everyone will have it and to avoid pasting a lot of code. if you run this you will see it's quite a long and nested array. what i'm trying to do is to read from my pref file and then go through each item in the array keeping what i want and then write back to it. my question is if i try to write back a long and nested array to my pref file how should i quote it or what kind of escape characters do i maybe need to use? i'm actually doing this in cocoa which is just a unix wrapper in this case and i can read my file fine, but writing back i can never get it to go through. the read results in cocoa are exactly like in terminal starting and ending with ( & { and i'm thinking something is missing when i go to write back an array. hope that makes sense and thank you! 🙂
rick
note: i'm aware the code to write is like below. it's just the last part giving me trouble.
defaults write com.mycompany.myfile arrayname -array ???
2 replies
Sign in or join Beachball Help to reply.
- 0
- 0