Created
January 30, 2013 11:05
-
-
Save Dimillian/4672471 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
//Creating a file path under iOS: | |
//1) Search for the app's documents directory (copy+paste from Documentation) | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *documentsDirectory = [paths objectAtIndex:0]; | |
//2) Create the full file path by appending the desired file name | |
NSString *yourArrayFileName = [documentsDirectory stringByAppendingPathComponent:@"example.dat"]; | |
//Load the array | |
NSMutableArray *yourArray = [[NSMutableArray alloc] initWithContentsOfFile: yourArrayFileName]; | |
if(yourArray == nil) | |
{ | |
//Array file didn't exist... create a new one | |
yourArray = [[NSMutableArray alloc] initWithCapacity:10]; | |
//Fill with default values | |
} | |
... | |
//Use the content | |
... | |
//Save the array | |
[yourArray writeToFile:yourArrayFileName atomically:YES]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment