From e2eb9397b85b1b6ec8a1b2b170f0d54f33f07f20 Mon Sep 17 00:00:00 2001 From: Eddie Ehlin Date: Mon, 14 Jan 2013 21:55:03 +0100 Subject: Refactored InstaBean into InstantExtraction which also resulted in a more general core data entity for handling configurations. Config variables related to instant extraction is prefixed with instantExtraction. --- iBean/iBean.xcodeproj/project.pbxproj | 38 +++--- .../UserInterfaceState.xcuserstate | Bin 33497 -> 34948 bytes iBean/iBean/.DS_Store | Bin 6148 -> 6148 bytes iBean/iBean/AppDelegate+Storage.h | 6 +- iBean/iBean/AppDelegate+Storage.m | 27 +++- iBean/iBean/Configuration+Interface.h | 13 ++ iBean/iBean/Configuration+Interface.m | 13 ++ iBean/iBean/Configuration.h | 17 +++ iBean/iBean/Configuration.m | 16 +++ iBean/iBean/InstaBeanConfiguration.h | 17 --- iBean/iBean/InstaBeanConfiguration.m | 16 --- iBean/iBean/InstaBeanViewController.h | 34 ----- iBean/iBean/InstaBeanViewController.m | 142 --------------------- iBean/iBean/InstantExtractionViewController.h | 34 +++++ iBean/iBean/InstantExtractionViewController.m | 142 +++++++++++++++++++++ .../iBean.xcdatamodeld/iBean.xcdatamodel/contents | 6 +- iBean/iBean/iPhoneStoryboard.storyboard | 8 +- 17 files changed, 287 insertions(+), 242 deletions(-) create mode 100644 iBean/iBean/Configuration+Interface.h create mode 100644 iBean/iBean/Configuration+Interface.m create mode 100644 iBean/iBean/Configuration.h create mode 100644 iBean/iBean/Configuration.m delete mode 100644 iBean/iBean/InstaBeanConfiguration.h delete mode 100644 iBean/iBean/InstaBeanConfiguration.m delete mode 100644 iBean/iBean/InstaBeanViewController.h delete mode 100644 iBean/iBean/InstaBeanViewController.m create mode 100644 iBean/iBean/InstantExtractionViewController.h create mode 100644 iBean/iBean/InstantExtractionViewController.m (limited to 'iBean') diff --git a/iBean/iBean.xcodeproj/project.pbxproj b/iBean/iBean.xcodeproj/project.pbxproj index 68cbbd0..5775776 100644 --- a/iBean/iBean.xcodeproj/project.pbxproj +++ b/iBean/iBean.xcodeproj/project.pbxproj @@ -19,8 +19,6 @@ 020C55B01691014E00D8224C /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 020C55AF1691014E00D8224C /* Default-568h@2x.png */; }; 020C55B31691014E00D8224C /* iBean.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 020C55B11691014E00D8224C /* iBean.xcdatamodeld */; }; 020C55BD169101FB00D8224C /* iPhoneStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 020C55BC169101FB00D8224C /* iPhoneStoryboard.storyboard */; }; - 020C55C41691059800D8224C /* InstaBeanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C55C31691059800D8224C /* InstaBeanViewController.m */; }; - 020C55C716910EAD00D8224C /* InstaBeanConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C55C616910EAD00D8224C /* InstaBeanConfiguration.m */; }; 020C55CA1691100000D8224C /* AppDelegate+Storage.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C55C91691100000D8224C /* AppDelegate+Storage.m */; }; 020C55FA16983E9900D8224C /* BeanCollectionListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C55F916983E9900D8224C /* BeanCollectionListViewController.m */; }; 020C560316989D4500D8224C /* BeanCollectionInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C560216989D4500D8224C /* BeanCollectionInfoViewController.m */; }; @@ -32,6 +30,9 @@ 020C5683169F5FBB00D8224C /* BeanCollection+Interface.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C5682169F5FBB00D8224C /* BeanCollection+Interface.m */; }; 020C568F16A1CE0E00D8224C /* EditBeanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C568E16A1CE0E00D8224C /* EditBeanViewController.m */; }; 020C569316A1E55600D8224C /* ExtractionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C569216A1E55600D8224C /* ExtractionViewController.m */; }; + 020C569916A49C5900D8224C /* Configuration.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C569816A49C5900D8224C /* Configuration.m */; }; + 020C569C16A49C8300D8224C /* Configuration+Interface.m in Sources */ = {isa = PBXBuildFile; fileRef = 020C569B16A49C8300D8224C /* Configuration+Interface.m */; }; + 024F676D16A4A61D004A1201 /* InstantExtractionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 024F676C16A4A61D004A1201 /* InstantExtractionViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -51,10 +52,6 @@ 020C55AF1691014E00D8224C /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 020C55B21691014E00D8224C /* iBean.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = iBean.xcdatamodel; sourceTree = ""; }; 020C55BC169101FB00D8224C /* iPhoneStoryboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = iPhoneStoryboard.storyboard; sourceTree = ""; }; - 020C55C21691059800D8224C /* InstaBeanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstaBeanViewController.h; sourceTree = ""; }; - 020C55C31691059800D8224C /* InstaBeanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstaBeanViewController.m; sourceTree = ""; }; - 020C55C516910EAD00D8224C /* InstaBeanConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstaBeanConfiguration.h; sourceTree = ""; }; - 020C55C616910EAD00D8224C /* InstaBeanConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstaBeanConfiguration.m; sourceTree = ""; }; 020C55C81691100000D8224C /* AppDelegate+Storage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+Storage.h"; sourceTree = ""; }; 020C55C91691100000D8224C /* AppDelegate+Storage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+Storage.m"; sourceTree = ""; }; 020C55F816983E9900D8224C /* BeanCollectionListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCollectionListViewController.h; sourceTree = ""; }; @@ -77,6 +74,12 @@ 020C568E16A1CE0E00D8224C /* EditBeanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EditBeanViewController.m; sourceTree = ""; }; 020C569116A1E55600D8224C /* ExtractionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtractionViewController.h; sourceTree = ""; }; 020C569216A1E55600D8224C /* ExtractionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExtractionViewController.m; sourceTree = ""; }; + 020C569716A49C5900D8224C /* Configuration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Configuration.h; sourceTree = ""; }; + 020C569816A49C5900D8224C /* Configuration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Configuration.m; sourceTree = ""; }; + 020C569A16A49C8300D8224C /* Configuration+Interface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Configuration+Interface.h"; sourceTree = ""; }; + 020C569B16A49C8300D8224C /* Configuration+Interface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Configuration+Interface.m"; sourceTree = ""; }; + 024F676B16A4A61D004A1201 /* InstantExtractionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstantExtractionViewController.h; sourceTree = ""; }; + 024F676C16A4A61D004A1201 /* InstantExtractionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstantExtractionViewController.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -126,8 +129,9 @@ isa = PBXGroup; children = ( 020C55D31695C2C800D8224C /* iBean */, + 020C55B9169101A300D8224C /* InstantExtraction */, + 020C55DF169792F800D8224C /* Data */, 020C55BB169101CE00D8224C /* Storyboards */, - 020C55B9169101A300D8224C /* InstaBean */, 020C55A81691014E00D8224C /* AppDelegate.h */, 020C55A91691014E00D8224C /* AppDelegate.m */, 020C55B11691014E00D8224C /* iBean.xcdatamodeld */, @@ -152,15 +156,13 @@ name = "Supporting Files"; sourceTree = ""; }; - 020C55B9169101A300D8224C /* InstaBean */ = { + 020C55B9169101A300D8224C /* InstantExtraction */ = { isa = PBXGroup; children = ( - 020C55C516910EAD00D8224C /* InstaBeanConfiguration.h */, - 020C55C616910EAD00D8224C /* InstaBeanConfiguration.m */, - 020C55C21691059800D8224C /* InstaBeanViewController.h */, - 020C55C31691059800D8224C /* InstaBeanViewController.m */, + 024F676B16A4A61D004A1201 /* InstantExtractionViewController.h */, + 024F676C16A4A61D004A1201 /* InstantExtractionViewController.m */, ); - name = InstaBean; + name = InstantExtraction; sourceTree = ""; }; 020C55BB169101CE00D8224C /* Storyboards */ = { @@ -179,7 +181,6 @@ 020C56071698F4DC00D8224C /* Step 2 - BeanCollectionBeanList */, 020C566E169E1ACB00D8224C /* Step 3 - Bean */, 020C569016A1E50200D8224C /* Step 4 - Extraction */, - 020C55DF169792F800D8224C /* Data */, ); name = iBean; sourceTree = ""; @@ -188,6 +189,8 @@ isa = PBXGroup; children = ( 020C5684169F603700D8224C /* Interface */, + 020C569716A49C5900D8224C /* Configuration.h */, + 020C569816A49C5900D8224C /* Configuration.m */, 020C567B169F597300D8224C /* BeanCollection.h */, 020C567C169F597300D8224C /* BeanCollection.m */, 020C5678169F597300D8224C /* Bean.h */, @@ -241,6 +244,8 @@ 020C567F169F5E9900D8224C /* Bean+Interface.m */, 020C5681169F5FBA00D8224C /* BeanCollection+Interface.h */, 020C5682169F5FBB00D8224C /* BeanCollection+Interface.m */, + 020C569A16A49C8300D8224C /* Configuration+Interface.h */, + 020C569B16A49C8300D8224C /* Configuration+Interface.m */, ); name = Interface; sourceTree = ""; @@ -323,8 +328,6 @@ 020C55A61691014E00D8224C /* main.m in Sources */, 020C55AA1691014E00D8224C /* AppDelegate.m in Sources */, 020C55B31691014E00D8224C /* iBean.xcdatamodeld in Sources */, - 020C55C41691059800D8224C /* InstaBeanViewController.m in Sources */, - 020C55C716910EAD00D8224C /* InstaBeanConfiguration.m in Sources */, 020C55CA1691100000D8224C /* AppDelegate+Storage.m in Sources */, 020C55FA16983E9900D8224C /* BeanCollectionListViewController.m in Sources */, 020C560316989D4500D8224C /* BeanCollectionInfoViewController.m in Sources */, @@ -336,6 +339,9 @@ 020C5683169F5FBB00D8224C /* BeanCollection+Interface.m in Sources */, 020C568F16A1CE0E00D8224C /* EditBeanViewController.m in Sources */, 020C569316A1E55600D8224C /* ExtractionViewController.m in Sources */, + 020C569916A49C5900D8224C /* Configuration.m in Sources */, + 020C569C16A49C8300D8224C /* Configuration+Interface.m in Sources */, + 024F676D16A4A61D004A1201 /* InstantExtractionViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate index ca0e38e..59502e2 100644 Binary files a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate and b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/iBean/iBean/.DS_Store b/iBean/iBean/.DS_Store index 3be0f60..9578c17 100644 Binary files a/iBean/iBean/.DS_Store and b/iBean/iBean/.DS_Store differ diff --git a/iBean/iBean/AppDelegate+Storage.h b/iBean/iBean/AppDelegate+Storage.h index e56b8bf..bec63e0 100644 --- a/iBean/iBean/AppDelegate+Storage.h +++ b/iBean/iBean/AppDelegate+Storage.h @@ -7,7 +7,7 @@ // #import "AppDelegate.h" -@class InstaBeanConfiguration; +@class Configuration; @class BeanCollection; @class Bean; @@ -24,8 +24,8 @@ - (void) rollback; -#pragma mark - InstaBean related storage methods -- (InstaBeanConfiguration*) getInstaBeanConfiguration; +#pragma mark - iBean configuration related methods +- (Configuration*) getConfiguration; #pragma mark - iBean related storage methods diff --git a/iBean/iBean/AppDelegate+Storage.m b/iBean/iBean/AppDelegate+Storage.m index f678397..5668bd5 100644 --- a/iBean/iBean/AppDelegate+Storage.m +++ b/iBean/iBean/AppDelegate+Storage.m @@ -7,7 +7,7 @@ // #import "AppDelegate+Storage.h" -#import "InstaBeanConfiguration.h" +#import "Configuration+Interface.h" #import "BeanCollection.h" @implementation AppDelegate (Storage) @@ -41,13 +41,13 @@ } #pragma mark - InstaBean related storage methods -- (InstaBeanConfiguration*) getInstaBeanConfiguration +- (Configuration*) getConfiguration { - InstaBeanConfiguration* config = nil; + Configuration* config = nil; if (self.managedObjectContext) { //Note: There should only be ONE entity of this type. - NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"InstaBeanConfiguration"]; + NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Configuration"]; [fetchRequest setFetchLimit:1]; NSError *fetchRequestError = nil; @@ -55,7 +55,7 @@ if (fetchRequestResult == nil || fetchRequestError != nil) { - NSLog(@"getInstaBeanConfiguration - Fetch request resulted in an error!"); + NSLog(@"getConfiguration - Fetch request resulted in an error!"); UIAlertView *loadErrorAlert = [[UIAlertView alloc] initWithTitle:@"Load error!" @@ -65,8 +65,21 @@ } else if (fetchRequestResult.count == 0) { - config = [NSEntityDescription insertNewObjectForEntityForName:@"InstaBeanConfiguration" inManagedObjectContext:self.managedObjectContext]; - config.extractionTime = [NSNumber numberWithDouble:25.0f]; + config = [NSEntityDescription insertNewObjectForEntityForName:@"Configuration" inManagedObjectContext:self.managedObjectContext]; + if (config != nil) + { + //Set default configuration values: + config.instantExtractionTime = [NSNumber numberWithDouble:25.0f]; + } + else + { + UIAlertView *createConfigurationAlert = [[UIAlertView alloc] + initWithTitle:@"Create config error!" + message:@"iBean unable to create configuration object.\n(Please check memory available.)" + delegate:nil + cancelButtonTitle:@"OK" otherButtonTitles: nil]; + [createConfigurationAlert show]; + } } else { diff --git a/iBean/iBean/Configuration+Interface.h b/iBean/iBean/Configuration+Interface.h new file mode 100644 index 0000000..d2660b7 --- /dev/null +++ b/iBean/iBean/Configuration+Interface.h @@ -0,0 +1,13 @@ +// +// Configuration+Interface.h +// iBean +// +// Created by Eddie Ehlin on 2013-01-14. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "Configuration.h" + +@interface Configuration (Interface) + +@end diff --git a/iBean/iBean/Configuration+Interface.m b/iBean/iBean/Configuration+Interface.m new file mode 100644 index 0000000..549997e --- /dev/null +++ b/iBean/iBean/Configuration+Interface.m @@ -0,0 +1,13 @@ +// +// Configuration+Interface.m +// iBean +// +// Created by Eddie Ehlin on 2013-01-14. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "Configuration+Interface.h" + +@implementation Configuration (Interface) + +@end diff --git a/iBean/iBean/Configuration.h b/iBean/iBean/Configuration.h new file mode 100644 index 0000000..bb7b24c --- /dev/null +++ b/iBean/iBean/Configuration.h @@ -0,0 +1,17 @@ +// +// Configuration.h +// iBean +// +// Created by Eddie Ehlin on 2013-01-14. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import +#import + + +@interface Configuration : NSManagedObject + +@property (nonatomic, retain) NSNumber * instantExtractionTime; + +@end diff --git a/iBean/iBean/Configuration.m b/iBean/iBean/Configuration.m new file mode 100644 index 0000000..6fde89e --- /dev/null +++ b/iBean/iBean/Configuration.m @@ -0,0 +1,16 @@ +// +// Configuration.m +// iBean +// +// Created by Eddie Ehlin on 2013-01-14. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "Configuration.h" + + +@implementation Configuration + +@dynamic instantExtractionTime; + +@end diff --git a/iBean/iBean/InstaBeanConfiguration.h b/iBean/iBean/InstaBeanConfiguration.h deleted file mode 100644 index ca985a7..0000000 --- a/iBean/iBean/InstaBeanConfiguration.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// InstaBeanConfiguration.h -// iBean -// -// Created by Eddie Ehlin on 2012-12-31. -// Copyright (c) 2012 Eddie Ehlin. All rights reserved. -// - -#import -#import - - -@interface InstaBeanConfiguration : NSManagedObject - -@property (nonatomic, retain) NSNumber * extractionTime; - -@end diff --git a/iBean/iBean/InstaBeanConfiguration.m b/iBean/iBean/InstaBeanConfiguration.m deleted file mode 100644 index c80cc72..0000000 --- a/iBean/iBean/InstaBeanConfiguration.m +++ /dev/null @@ -1,16 +0,0 @@ -// -// InstaBeanConfiguration.m -// iBean -// -// Created by Eddie Ehlin on 2012-12-31. -// Copyright (c) 2012 Eddie Ehlin. All rights reserved. -// - -#import "InstaBeanConfiguration.h" - - -@implementation InstaBeanConfiguration - -@dynamic extractionTime; - -@end diff --git a/iBean/iBean/InstaBeanViewController.h b/iBean/iBean/InstaBeanViewController.h deleted file mode 100644 index f21c3bf..0000000 --- a/iBean/iBean/InstaBeanViewController.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// InstaBeanViewController.h -// iBean -// -// Created by Eddie Ehlin on 2012-12-31. -// Copyright (c) 2012 Eddie Ehlin. All rights reserved. -// - -#import -#import "InstaBeanConfiguration.h" - -@interface InstaBeanViewController : UIViewController - -@property (nonatomic, assign) double extractionProgress; -@property (nonatomic, strong) NSTimer* timer; -@property (nonatomic, strong) InstaBeanConfiguration *configuration; - -/* Utility methods */ -- (void) initInstaBean; -- (void) updateExtractionSettingLabel; -- (void) updateExtractionProgressLabel; -- (void) haltExtractionTimer; - -/* UI Outlets */ -@property (weak, nonatomic) IBOutlet UILabel *extractionSettingLabel; -@property (weak, nonatomic) IBOutlet UIButton *extractionButton; -@property (weak, nonatomic) IBOutlet UIStepper *extractionSettingStepper; -@property (weak, nonatomic) IBOutlet UILabel *extractionProgressLabel; - -/* UI Actions */ -- (IBAction)startExtraction:(id)sender; -- (IBAction)setExtractionTimer:(id)sender; - -@end diff --git a/iBean/iBean/InstaBeanViewController.m b/iBean/iBean/InstaBeanViewController.m deleted file mode 100644 index 5d3d566..0000000 --- a/iBean/iBean/InstaBeanViewController.m +++ /dev/null @@ -1,142 +0,0 @@ -// -// InstaBeanViewController.m -// iBean -// -// Created by Eddie Ehlin on 2012-12-31. -// Copyright (c) 2012 Eddie Ehlin. All rights reserved. -// - -#import "InstaBeanViewController.h" -#import "AppDelegate+Storage.h" - -@interface InstaBeanViewController () - -@end - -@implementation InstaBeanViewController - - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - // Custom initialization - } - return self; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - // Do any additional setup after loading the view. -} - -- (void) viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - [self initInstaBean]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - - -/***************************************************** - Utility methods - *****************************************************/ -#pragma mark - Utility methods -- (void) initInstaBean -{ - if (self.configuration == nil) - { - NSLog(@"Loading & setting stepper!"); - self.configuration = [(AppDelegate*) [[UIApplication sharedApplication] delegate] getInstaBeanConfiguration]; - - if (self.configuration == nil) - { - NSLog(@"initInstaBean received nil for configuration!"); - return; - } - } - - [self.extractionSettingStepper setValue:[self.configuration.extractionTime doubleValue]]; - [self updateExtractionSettingLabel]; -} - -- (void) updateExtractionProgressLabel -{ - self.extractionProgress += 0.1f; - self.extractionProgressLabel.text = [NSString stringWithFormat:@"%1.1f", self.extractionProgress]; - - if (self.extractionProgress >= self.extractionSettingStepper.value) - { - NSLog(@"Timer reached its limit!"); - [self haltExtractionTimer]; - } -} - -- (void) updateExtractionSettingLabel -{ - self.extractionSettingLabel.text = [NSString stringWithFormat:@"%1.0f", self.extractionSettingStepper.value]; -} - -- (void) haltExtractionTimer -{ - if (self.timer != nil) - { - [self.timer invalidate]; - self.timer = nil; - - //Return UI to "Start extraction" state. - [self.extractionButton setTitle:@"Start extraction" forState:UIControlStateNormal]; - [self.extractionSettingStepper setEnabled:YES]; - } -} - -/***************************************************** - UI Actions -*****************************************************/ -#pragma mark - IBActions -- (IBAction)startExtraction:(id)sender { - - //Extraction in progress? - if (self.timer == nil) - { - self.extractionProgress = 0.0f; - [self.extractionButton setTitle:@"Stop extraction" forState:UIControlStateNormal]; - [self.extractionSettingStepper setEnabled:NO]; - - self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(updateExtractionProgressLabel) userInfo:nil repeats:YES]; - - } - else - { - [self haltExtractionTimer]; - } -} - -- (IBAction)setExtractionTimer:(id)sender { - - if (self.configuration != nil) - { - self.configuration.extractionTime = [NSNumber numberWithDouble:self.extractionSettingStepper.value]; - - //Let's save our config. - NSError* error = [(AppDelegate*) [[UIApplication sharedApplication] delegate] save]; - if (error != nil) - { - NSLog(@"InstaBean unable to save configuration!"); - UIAlertView *saveErrorAlert = [[UIAlertView alloc] - initWithTitle:@"Save error!" - message:@"Unable to save configuration." - delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [saveErrorAlert show]; - } - } - - [self updateExtractionSettingLabel]; -} -@end diff --git a/iBean/iBean/InstantExtractionViewController.h b/iBean/iBean/InstantExtractionViewController.h new file mode 100644 index 0000000..e8ec739 --- /dev/null +++ b/iBean/iBean/InstantExtractionViewController.h @@ -0,0 +1,34 @@ +// +// InstantExtractionViewController.h +// iBean +// +// Created by Eddie Ehlin on 2012-12-31. +// Copyright (c) 2012 Eddie Ehlin. All rights reserved. +// + +#import +#import "Configuration+Interface.h" + +@interface InstantExtractionViewController : UIViewController + +@property (nonatomic, assign) double extractionProgress; +@property (nonatomic, strong) NSTimer* timer; +@property (nonatomic, strong) Configuration *configuration; + +/* Utility methods */ +- (void) initViewController; +- (void) updateExtractionSettingLabel; +- (void) updateExtractionProgressLabel; +- (void) haltExtractionTimer; + +/* UI Outlets */ +@property (weak, nonatomic) IBOutlet UILabel *extractionSettingLabel; +@property (weak, nonatomic) IBOutlet UIButton *extractionButton; +@property (weak, nonatomic) IBOutlet UIStepper *extractionSettingStepper; +@property (weak, nonatomic) IBOutlet UILabel *extractionProgressLabel; + +/* UI Actions */ +- (IBAction)startExtraction:(id)sender; +- (IBAction)setExtractionTimer:(id)sender; + +@end diff --git a/iBean/iBean/InstantExtractionViewController.m b/iBean/iBean/InstantExtractionViewController.m new file mode 100644 index 0000000..699d2c8 --- /dev/null +++ b/iBean/iBean/InstantExtractionViewController.m @@ -0,0 +1,142 @@ +// +// InstantExtractionViewController.m +// iBean +// +// Created by Eddie Ehlin on 2012-12-31. +// Copyright (c) 2012 Eddie Ehlin. All rights reserved. +// + +#import "InstantExtractionViewController.h" +#import "AppDelegate+Storage.h" + +@interface InstantExtractionViewController () + +@end + +@implementation InstantExtractionViewController + + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + +- (void) viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + [self initViewController]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + +/***************************************************** + Utility methods + *****************************************************/ +#pragma mark - Utility methods +- (void) initViewController +{ + if (self.configuration == nil) + { + NSLog(@"Loading & setting stepper!"); + self.configuration = [(AppDelegate*) [[UIApplication sharedApplication] delegate] getConfiguration]; + + if (self.configuration == nil) + { + NSLog(@"InstantExtractionViewController - initViewController: received nil for configuration!"); + return; + } + } + + [self.extractionSettingStepper setValue:[self.configuration.instantExtractionTime doubleValue]]; + [self updateExtractionSettingLabel]; +} + +- (void) updateExtractionProgressLabel +{ + self.extractionProgress += 0.1f; + self.extractionProgressLabel.text = [NSString stringWithFormat:@"%1.1f", self.extractionProgress]; + + if (self.extractionProgress >= self.extractionSettingStepper.value) + { + NSLog(@"Timer reached its limit!"); + [self haltExtractionTimer]; + } +} + +- (void) updateExtractionSettingLabel +{ + self.extractionSettingLabel.text = [NSString stringWithFormat:@"%1.0f", self.extractionSettingStepper.value]; +} + +- (void) haltExtractionTimer +{ + if (self.timer != nil) + { + [self.timer invalidate]; + self.timer = nil; + + //Return UI to "Start extraction" state. + [self.extractionButton setTitle:@"Start extraction" forState:UIControlStateNormal]; + [self.extractionSettingStepper setEnabled:YES]; + } +} + +/***************************************************** + UI Actions +*****************************************************/ +#pragma mark - IBActions +- (IBAction)startExtraction:(id)sender { + + //Extraction in progress? + if (self.timer == nil) + { + self.extractionProgress = 0.0f; + [self.extractionButton setTitle:@"Stop extraction" forState:UIControlStateNormal]; + [self.extractionSettingStepper setEnabled:NO]; + + self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(updateExtractionProgressLabel) userInfo:nil repeats:YES]; + + } + else + { + [self haltExtractionTimer]; + } +} + +- (IBAction)setExtractionTimer:(id)sender { + + if (self.configuration != nil) + { + self.configuration.instantExtractionTime = [NSNumber numberWithDouble:self.extractionSettingStepper.value]; + + //Let's save our config. + NSError* error = [(AppDelegate*) [[UIApplication sharedApplication] delegate] save]; + if (error != nil) + { + NSLog(@"InstantExtraction unable to save configuration!"); + UIAlertView *saveErrorAlert = [[UIAlertView alloc] + initWithTitle:@"Save error!" + message:@"Unable to save configuration." + delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [saveErrorAlert show]; + } + } + + [self updateExtractionSettingLabel]; +} +@end diff --git a/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents b/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents index f7f7901..98664e2 100644 --- a/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents +++ b/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents @@ -15,12 +15,12 @@ - - + + - + \ No newline at end of file diff --git a/iBean/iBean/iPhoneStoryboard.storyboard b/iBean/iBean/iPhoneStoryboard.storyboard index 752dcfa..358e404 100644 --- a/iBean/iBean/iPhoneStoryboard.storyboard +++ b/iBean/iBean/iPhoneStoryboard.storyboard @@ -56,10 +56,10 @@ - + - + @@ -696,8 +696,8 @@ - - + + -- cgit v1.2.3