Created
October 13, 2018 22:52
-
-
Save genemyers/5fd8de5e7339ac23d6421ea1076cd0eb 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
| // Get the URL for the document directory | |
| NSFileManager *fileManager = [[NSFileManager alloc] init]; | |
| NSURL *documentDirectoryURL = [[fileManager URLsForDocumentDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] objectAtIndex:0]; | |
| // Turn the filename into a string safe for use in a URL | |
| NSString *safeString = [@"scores.plist" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
| // Create an array for the score | |
| NSMutableArray *array = [[NSMutableArray alloc] init]; | |
| [array addObject:[NSNumber numberWithInt:score]]; | |
| // Write this array to a URL | |
| NSURL *arrayURL = [NSURL URLWithString:safeString relativeToURL:documentDirectoryURL]; | |
| [array writeToURL:arrayURL atomically:YES]; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from stack overflow
https://stackoverflow.com/questions/7059966/how-to-use-plist-in-ios-programming