iOS - how to read and write a plist of this format
Posted
by
Suchi
on Stack Overflow
See other posts from Stack Overflow
or by Suchi
Published on 2012-10-01T21:26:49Z
Indexed on
2012/10/03
3:37 UTC
Read the original article
Hit count: 267
I have an xml of the following format -
<plist version="1.0">
<array>
<dict>...</dict>
<dict>...</dict>
</array>
</plist>
I am trying to write it into a plist using -
NSDictionary *temp = [NSPropertyListSerialization propertyListWithData:returnData options:NSPropertyListImmutable format:&format error:&errorDesc];
[self writeToPlistFile:@"myList.plist" : temp];
where the method is
-(BOOL)writeToPlistFile:(NSString*)filename:(NSDictionary*)data{
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * documentsDirectory = [paths objectAtIndex:0];
NSString * path = [documentsDirectory stringByAppendingPathComponent:filename];
BOOL didWriteSuccessfull = [data writeToFile:path atomically:YES];
return didWriteSuccessfull;
}
I then want to read it and place it into a dictionary. How would I do that?
© Stack Overflow or respective owner