- (void)readWritePlist:(BOOL)readonly{
//get the documents directory:
NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//make a file name to write the data to using the
//documents directory:
NSString *fullFileName = [NSString stringWithFormat:@"%@/arraydata.plist", documentsDirectory];
NSLog(@"fullFileName: %@",fullFileName);
//create an array and add values to it:
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:@"One"];
[array addObject:@"Two"];
[array addObject:@"Three"];
//this statement is what actually writes out the array
//to the file system:
[array writeToFile:fullFileName atomically:NO];
//retrieve the array contents.重新获取那个文件的内容
NSMutableArray *array2 = [[NSMutableArray alloc] initWithContentsOfFile:fullFileName];
NSLog(@"readWritePlist: %@",array2);
[array2 release];