Skip to content

Instantly share code, notes, and snippets.

@sumardi
Created February 3, 2012 11:16
Show Gist options
  • Select an option

  • Save sumardi/1729716 to your computer and use it in GitHub Desktop.

Select an option

Save sumardi/1729716 to your computer and use it in GitHub Desktop.
[iOSDev] Reading from plist
- (id)readPlist:(NSString *)fileName {
NSData *plistData;
NSString *error;
NSPropertyListFormat format;
id plist;
NSString *localizedPath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"plist"];
plistData = [NSData dataWithContentsOfFile:localizedPath]; 
plist = [NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error];
if (!plist) {
NSLog(@"Error reading plist from file '%s', error = '%s'", [localizedPath UTF8String], [error UTF8String]);
[error release];
}
return plist;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment