ios - Add index in plist file programmatically -


i creating plist file programmatically direct documents directory. here code..

nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *path = [documentsdirectory stringbyappendingpathcomponent:@"mylist.plist"]; nsfilemanager *filemanager = [nsfilemanager defaultmanager];  if (![filemanager fileexistsatpath: path]) {     path = [documentsdirectory stringbyappendingpathcomponent: [nsstring stringwithformat: @"mylist.plist"] ]; } nsmutablearray *data ; if ([filemanager fileexistsatpath: path]) {     data = [[nsmutablearray alloc] initwithcontentsoffile: path];  } else {     // if file doesn’t exist, create empty dictionary     data = [[nsmutablearray alloc] init]; } data = [[nsmutablearray  alloc] initwithcapacity:5]; [data addobject:value1]; [data addobject:value2]; [data addobject:value3]; 

it creates plist file format..

<array>         <string>1</string>         <string>2</string>         <string>3</string> </array> 

now, want add index like,

<array>         <string>1</string>         <string>2</string>         <string>3</string> </array> <array>         <string>11</string>         <string>22</string>         <string>33</string> </array>   

how can add index programmatically in plist file ?
or suggestions appreciated !!

thank you

try

nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *path = [documentsdirectory stringbyappendingpathcomponent:@"mylist.plist"];  nsmutablearray *data = [[nsmutablearray alloc] initwithcontentsoffile: path]; if (!data) {     data = [nsmutablearray array]; }  [data addobject:@[value1,value2,value3]];  [data writetofile:path atomically:yes]; 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -