Skip to content

Instantly share code, notes, and snippets.

@rabinjoshi
Created June 18, 2011 05:04
Show Gist options
  • Save rabinjoshi/1032821 to your computer and use it in GitHub Desktop.
Save rabinjoshi/1032821 to your computer and use it in GitHub Desktop.
Archiving objects
NSDictionary *glossary = [NSDictionary dictionaryWithObjectsAndKeys:
@"A class defined so other classes can inherit from it.", @"abstract class",
@"To implement all the methods defined in a protocol", @"adopt",
@"Storing an object for later use. ", @"archiving",
nil
];
// Storing
if ([glossary writeToFile: @"/Users/rabinjoshi/Desktop/glossary.plist" atomically: YES] == NO)
NSLog (@"Save to file failed!");
// Retrieving
NSDictionary *glossary2;
glossary2 = [NSDictionary dictionaryWithContentsOfFile: @"/Users/rabinjoshi/Desktop/glossary.plist"];
for ( NSString *key in glossary )
NSLog (@"%@: %@", key, [glossary2 objectForKey: key]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment