Created
February 3, 2012 11:16
-
-
Save sumardi/1729716 to your computer and use it in GitHub Desktop.
[iOSDev] Reading from plist
This file contains hidden or 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
| - (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