I have a dictionary .plist that has a subarray in it, however during the conversion in Json in converts to an array. The item is “profile” in the image below, as you can see, it’s a Dictionary, how do I turn programmatically convert into an array”:
alt text http://www.baublet.com/images/dict2.png
I would also like the items in the dictionary to have Item 0, Item 1, etc. so it looks like this when completed so I can use it in a drill down UItable.
alt text http://www.baublet.com/images/array4.png
Thanks for the feedback on the question, I reworked it.
Michael
Given that the dictionary contains a series of key/value pairs, it isn’t clear what turning it into an array even means. As well, you haven’t said what you want to do with the array.
Do you want just the values? Do you need them in key,value,key,value order? Do they need to be in some order? Do you want the array to replace the dictionary? Do you need the array by itself?
Given the extent of the rewriting you are doing, I would suggest creating a container — NSMutableDictionary or NSMutableArray, as appropriate — and then walking down the existing container, inserting new items in your mutable container in whatever form you need.
It would be straightforward using
for (... in ...)to enumerate the dictionaries and arrays.As long as you continue to use the string values found within the original — there is no reason to copy them — then the memory use won’t be horribly egregious.
Relevant documentation:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Collections/Collections.html#//apple_ref/doc/uid/10000034i
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/PropertyLists/Introduction/Introduction.html#//apple_ref/doc/uid/10000048i