I was looking to create plist file in my application Documents folder programmatically in objective C. I created a folder in documents directory :
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *path = [NSString stringWithFormat:@"%@/Data.plist", documentsDirectoryPath];
I am trying to create plist file which will look like an XML file. /**** Required XML 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">
<array>
<dict>
<key>height</key>
<integer>4007</integer>
<key>name</key>
<string>map</string>
<key>width</key>
<integer>6008</integer>
</dict>
</array>
</plist>
/****Achieved file through code ****/
<?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>height</key>
<string>4007</string>
<key>name</key>
<string>map</string>
<key>width</key>
<string>6008</string>
</dict>
</plist>
The required file needs an array and inside the array we have a dictionary object. How can I change this ? I also know how to write the file to the path, but the major issue is how to create plist file and then read it ?