Skip to content

Instantly share code, notes, and snippets.

@sebastienwindal
Last active August 29, 2015 14:02
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 sebastienwindal/f894508839d125dccf22 to your computer and use it in GitHub Desktop.
Save sebastienwindal/f894508839d125dccf22 to your computer and use it in GitHub Desktop.
// .h file
@interface LessonManager : NSObject
@property (strong, nonatomic) NSString * imageTitle;
+ (instancetype) sharedInstance;
@end
// .m mfile
@implementation LessonManager
+ (instancetype)sharedInstance
{
// this whole thing ensures that this code is run once (at most), the plist parsing happens lazily,
// first time you call [LessonManager sharedInstance]
static dispatch_once_t once;
static id sharedInstance;
dispatch_once(&once, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
-(id) init
{
self = [super init];
if (self) {
// this is your code I copied here from your email
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"LessonContent1" ofType:@"plist"]];
NSArray *arrayList = [NSArray arrayWithArray:[dictionary objectForKey:@"LessonOneArray"]];
// Now a loop through Array to fetch single Item from catList which is Dictionary
[arrayList enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
self.imageTitle =[obj valueForKey:@"ImageName"];
}];
}
return self;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment