Created
December 11, 2010 00:17
-
-
Save ejknapp/737020 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(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