Skip to content

Instantly share code, notes, and snippets.

@kgleeson
Last active December 26, 2015 19:29
Show Gist options
  • Select an option

  • Save kgleeson/7201533 to your computer and use it in GitHub Desktop.

Select an option

Save kgleeson/7201533 to your computer and use it in GitHub Desktop.
- (void)loadTimersFromFile{
NSLog(@"loading...");
NSString *writableFilePath = [self getTimerFilePath:@"timersDict"];
timersDict = [NSMutableDictionary dictionaryWithContentsOfFile:writableFilePath];
coffeeTimers = [[NSMutableArray alloc] init];
for (NSString *item in [timersDict allKeys]) {
[coffeeTimers addObject:[[CTTimer alloc] initWithName:[[timersDict valueForKey:item] valueForKey:@"name"]
steepTime:[[[timersDict valueForKey:item] valueForKey:@"steep"] integerValue]
brewTime:[[[timersDict valueForKey:item] valueForKey:@"brew"] integerValue]]];
}
}
- (void)loadTimersFromFile{
NSLog(@"loading...");
NSString *writableFilePath = [self getTimerFilePath:@"timersDict"];
timersDict = [NSDictionary dictionaryWithContentsOfFile:writableFilePath];
for (id item in timersDict) {
[coffeeTimers addObject:[[CTTimer alloc] initWithName:[item valueForKey:@"name"]
steepTime:[item valueForKey:@"steep"]
brewTime:[item valueForKey:@"brew"]]];
}
}
Printing description of timersDict:
{
Aeropress = {
brew = 90;
name = Aeropress;
steep = 30;
};
Chemex = {
brew = 240;
name = Chemex;
steep = 30;
};
Espresso = {
brew = 28;
name = Espresso;
steep = 0;
};
"French Press" = {
brew = 180;
name = "French Press";
steep = 60;
};
"Pour over" = {
brew = 120;
name = "Pour over";
steep = 30;
};
}
2013-10-28 18:00:25.732 CoffeeTimer[29362:70b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFString 0x8d5a540> valueForUndefinedKey:]: this class is not key value coding-compliant for the key name.'
*** First throw call stack:
(
0 CoreFoundation 0x017415e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014c48b6 objc_exception_throw + 44
2 CoreFoundation 0x017d16a1 -[NSException raise] + 17
3 Foundation 0x01185b0a -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 282
4 Foundation 0x010f2b61 _NSGetUsingKeyValueGetter + 81
5 Foundation 0x010f219b -[NSObject(NSKeyValueCoding) valueForKey:] + 260
6 CoffeeTimer 0x000051ca -[ViewController loadTimersFromFile] + 554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment