we can use the code below
- (void)readPlist
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //1
NSString *documentsDirectory = [paths objectAtIndex:0]; //2
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Contacts.plist"];
listOfItems = [[NSMutableArray alloc] initWithContentsOfFile:path];
}
- (void)writeToPlist
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //1
NSString *documentsDirectory = [paths objectAtIndex:0]; //2
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Contacts.plist"];
[listOfItems writeToFile:path atomically:YES];
}
No comments:
Post a Comment