Last active
December 18, 2015 11:58
-
-
Save stephsharp/5778921 to your computer and use it in GitHub Desktop.
Snippet to read data from a property list
This file contains 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
// Helpful tutorial: | |
// http://www.theappcodeblog.com/2011/05/30/property-list-tutorial-using-plist-to-store-user-data/ | |
// Get property list from main bundle | |
NSString * plistPath = [[NSBundle mainBundle] pathForResource:@"PListName" ofType:@"plist"]; | |
// Read property list into memory as an NSData object | |
NSData * plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath]; | |
NSString * errorDesc = nil; | |
NSPropertyListFormat format; | |
// Convert static property list into dictionary object | |
NSDictionary * temp = (NSDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&errorDesc]; | |
if (!temp) | |
NSLog(@"Error reading plist: %@, format: %d", errorDesc, format); | |
// Use data from property list | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment