Skip to content

Instantly share code, notes, and snippets.

@dlinsin
Created September 10, 2011 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlinsin/1208372 to your computer and use it in GitHub Desktop.
Save dlinsin/1208372 to your computer and use it in GitHub Desktop.
Simple category to read plist as array
#import "NSArray+Plist.h"
@implementation NSArray (Plist)
+ (id)arrayFromPlist:(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;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment