Guest User

Untitled

a guest
Jan 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #import "NSArray+Plist.h"
  2.  
  3. @implementation NSArray (Plist)
  4.  
  5. + (id)arrayFromPlist:(NSString *)filename {
  6. NSData *plistData;
  7. NSString *error;
  8. NSPropertyListFormat format;
  9. id plist;
  10.  
  11. NSString *localizedPath = [[NSBundle mainBundle] pathForResource:filename ofType:@"plist"];
  12. plistData = [NSData dataWithContentsOfFile:localizedPath];
  13.  
  14. plist = [NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error];
  15. if (!plist) {
  16. NSLog(@"Error reading plist from file '%s', error = '%s'", [localizedPath UTF8String], [error UTF8String]);
  17. [error release];
  18. }
  19.  
  20. return plist;
  21. }
  22.  
  23. @end
Add Comment
Please, Sign In to add comment