Skip to content

Instantly share code, notes, and snippets.

@ejknapp
Created December 11, 2010 00:17
Show Gist options
  • Select an option

  • Save ejknapp/737020 to your computer and use it in GitHub Desktop.

Select an option

Save ejknapp/737020 to your computer and use it in GitHub Desktop.
-(void)saveData
{
NSString *prefixFilePath = pathInDocumentDirectory(@"prefix.plist");
NSString *wordsFilePath = pathInDocumentDirectory(@"words.plist");
[self.wordDictionary writeToFile:wordsFilePath atomically:YES];
[self.prefixes writeToFile:prefixFilePath atomically:YES];
}
- (void) loadData
{
NSString *prefixFilePath = pathInDocumentDirectory(@"prefix.plist");
NSString *wordsFilePath = pathInDocumentDirectory(@"words.plist");
//Does the file exist?
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:prefixFilePath]) {
prefixFilePath = [[NSBundle mainBundle]
pathForResource:@"prefix" ofType:@"plist"];
}
if (![fileManager fileExistsAtPath:wordsFilePath]) {
wordsFilePath = [[NSBundle mainBundle]
pathForResource:@"words" ofType:@"plist"];
}
NSLog(@"File Path: %@", wordsFilePath);
NSLog(@"File Path: %@", prefixFilePath);
self.prefixes = [NSMutableDictionary
dictionaryWithContentsOfFile:prefixFilePath];
self.wordDictionary = [NSMutableDictionary
dictionaryWithContentsOfFile:wordsFilePath];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment