Skip to content

Instantly share code, notes, and snippets.

@kerin
Created November 27, 2012 13:52
Show Gist options
  • Save kerin/4154315 to your computer and use it in GitHub Desktop.
Save kerin/4154315 to your computer and use it in GitHub Desktop.
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
NSString *errorDesc = nil;
NSPropertyListFormat format;
NSString *plistPath;
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES) objectAtIndex:0];
plistPath = [rootPath stringByAppendingPathComponent:@"genres.plist"];
if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath]) {
plistPath = [[NSBundle mainBundle] pathForResource:@"genres" ofType:@"plist"];
}
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
NSArray *plist = (NSArray *)[NSPropertyListSerialization
propertyListFromData:plistXML
mutabilityOption:NSPropertyListMutableContainersAndLeaves
format:&format
errorDescription:&errorDesc];
if (!plist) {
NSLog(@"Error reading plist: %@, format: %d", errorDesc, format);
}
self.genres = plist;
}
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment