// Write Plist file
int yourValue=1;
NSString *lastBookPath=[NSString stringWithFormat:@"%@/library/my.plist",[DocumentDirectory libraryDirectoryPath]];
NSMutableArray *lastBookArray = [NSMutableArray array];
NSMutableDictionary *dictionary;
dictionary = [NSMutableDictionary dictionary];
[dictionary setValue:[NSString stringWithFormat:@"%i",yourValue] forKey:@"Value"];
[lastBookArray addObject:dictionary];
[lastBookArray writeToFile:lastBookPath atomically:NO];
// Read Plist file
-(int)readPlistFile{
NSFileManager *fileManager=[NSFileManager defaultManager];
NSString *lastBookPath=[NSString stringWithFormat:@"%@/library/my.plist",[DocumentDirectory libraryDirectoryPath]];
if ([fileManager fileExistsAtPath:plistFilePath]){
NSArray *arrayThatWasRead = [NSArray arrayWithContentsOfFile:plistFilePath];
NSDictionary *dictionaryFromArrayThatWasRead = [arrayThatWasRead objectAtIndex:0];
return [[dictionaryFromArrayThatWasRead valueForKey:@"Value"]intValue];
}
return 0;
}
No comments:
Post a Comment