From e3f505842ceba21ae0d58886d7424162bbf395d4 Mon Sep 17 00:00:00 2001 From: Eddie Ehlin Date: Sun, 27 Jan 2013 12:46:33 +0100 Subject: Minor cleanup made to Instant Extraction. No explicit use of configuration object at any view controller - all changes/reads are done via storage methods. --- iBean/iBean.xcodeproj/project.pbxproj | 12 +++--- .../UserInterfaceState.xcuserstate | Bin 39557 -> 39507 bytes .../xcdebugger/Breakpoints.xcbkptlist | 18 ++++----- iBean/iBean/AppDelegate+Storage.h | 13 +++++++ iBean/iBean/AppDelegate+Storage.m | 30 ++++++++++++++- iBean/iBean/Configuration.h | 4 +- iBean/iBean/Configuration.m | 4 +- iBean/iBean/InstantExtractionViewController.h | 2 - iBean/iBean/InstantExtractionViewController.m | 42 ++++++--------------- .../iBean.xcdatamodeld/iBean.xcdatamodel/contents | 2 +- 10 files changed, 73 insertions(+), 54 deletions(-) diff --git a/iBean/iBean.xcodeproj/project.pbxproj b/iBean/iBean.xcodeproj/project.pbxproj index 22eba16..09178f0 100644 --- a/iBean/iBean.xcodeproj/project.pbxproj +++ b/iBean/iBean.xcodeproj/project.pbxproj @@ -30,9 +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 */; }; + 0276252616B5477800EE2F4E /* Configuration.m in Sources */ = {isa = PBXBuildFile; fileRef = 0276252516B5477800EE2F4E /* Configuration.m */; }; 02E557AE16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 02E557AD16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m */; }; 02E557B116A9CFB50080FBBA /* BeanCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 02E557B016A9CFB50080FBBA /* BeanCell.m */; }; 02E557BA16AC85A20080FBBA /* BeanCollectionExtractionScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 02E557B916AC85A20080FBBA /* BeanCollectionExtractionScrollView.m */; }; @@ -77,12 +77,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 = ""; }; + 0276252416B5477800EE2F4E /* Configuration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Configuration.h; sourceTree = ""; }; + 0276252516B5477800EE2F4E /* Configuration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Configuration.m; sourceTree = ""; }; 02E557AC16A9C1E40080FBBA /* BeanCollectionExtractionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCollectionExtractionViewController.h; sourceTree = ""; }; 02E557AD16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeanCollectionExtractionViewController.m; sourceTree = ""; }; 02E557AF16A9CFB50080FBBA /* BeanCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCell.h; sourceTree = ""; }; @@ -199,8 +199,8 @@ isa = PBXGroup; children = ( 020C5684169F603700D8224C /* Interface */, - 020C569716A49C5900D8224C /* Configuration.h */, - 020C569816A49C5900D8224C /* Configuration.m */, + 0276252416B5477800EE2F4E /* Configuration.h */, + 0276252516B5477800EE2F4E /* Configuration.m */, 020C567B169F597300D8224C /* BeanCollection.h */, 020C567C169F597300D8224C /* BeanCollection.m */, 020C5678169F597300D8224C /* Bean.h */, @@ -362,12 +362,12 @@ 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 */, 02E557AE16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m in Sources */, 02E557B116A9CFB50080FBBA /* BeanCell.m in Sources */, 02E557BA16AC85A20080FBBA /* BeanCollectionExtractionScrollView.m in Sources */, + 0276252616B5477800EE2F4E /* Configuration.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 c566724..7305da1 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.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist index 75119b6..c76aba4 100644 --- a/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist +++ b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -8,11 +8,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "iBean/InstantExtractionViewController.m" - timestampString = "380494622.652202" + timestampString = "380979696.779799" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "88" - endingLineNumber = "88" + startingLineNumber = "79" + endingLineNumber = "79" landmarkName = "-haltExtractionTimer" landmarkType = "5"> @@ -21,11 +21,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "iBean/InstantExtractionViewController.m" - timestampString = "380496617.591403" + timestampString = "380979696.779799" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "99" - endingLineNumber = "99" + startingLineNumber = "90" + endingLineNumber = "90" landmarkName = "-timerInterrupted" landmarkType = "5"> @@ -34,11 +34,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "iBean/AppDelegate+Storage.m" - timestampString = "380496246.739132" + timestampString = "380979696.779799" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "164" - endingLineNumber = "164" + startingLineNumber = "190" + endingLineNumber = "190" landmarkName = "-createTimer::::" landmarkType = "5"> diff --git a/iBean/iBean/AppDelegate+Storage.h b/iBean/iBean/AppDelegate+Storage.h index f444572..ad94cb6 100644 --- a/iBean/iBean/AppDelegate+Storage.h +++ b/iBean/iBean/AppDelegate+Storage.h @@ -27,6 +27,19 @@ #pragma mark - iBean configuration related methods - (Configuration*) getConfiguration; +//Extraction counter methods +/* +- (NSNumber*) getExtractionCount; +- (NSNumber*) increaseExtractionCount; +- (NSNumber*) decreaseExtractionCount; +- (void) resetExtractionCount; +*/ + +//Instant extraction related methods +- (NSError*) setInstantExtractionTimer: (NSNumber*) extractionTimer; +- (NSNumber*) getInstantExtractionTimer; + + #pragma mark - iBean related storage methods - (NSArray*) getBeanCollections; diff --git a/iBean/iBean/AppDelegate+Storage.m b/iBean/iBean/AppDelegate+Storage.m index 4532397..ca0e81d 100644 --- a/iBean/iBean/AppDelegate+Storage.m +++ b/iBean/iBean/AppDelegate+Storage.m @@ -40,7 +40,7 @@ } } -#pragma mark - InstaBean related storage methods +#pragma mark - iBean configuration related methods - (Configuration*) getConfiguration { Configuration* config = nil; @@ -69,7 +69,7 @@ if (config != nil) { //Set default configuration values: - config.instantExtractionTime = [NSNumber numberWithDouble:25.0f]; + config.instantExtractionTimer = [NSNumber numberWithDouble:25.0f]; } else { @@ -89,6 +89,32 @@ return config; } +#pragma mark - Instant extraction related methods (using Configuraiton) +- (NSError*)setInstantExtractionTimer:(NSNumber *)extractionTimer +{ + NSError *error = nil; + + Configuration* c = [self getConfiguration]; + if (c != nil) + { + c.instantExtractionTimer = extractionTimer; + error = [(AppDelegate*) [[UIApplication sharedApplication] delegate] save]; + } + return error; +} + +- (NSNumber*) getInstantExtractionTimer +{ + NSNumber* extractionTimerSetting = nil; + Configuration* c = [self getConfiguration]; + if (c != nil) + { + extractionTimerSetting = c.instantExtractionTimer; + } + return extractionTimerSetting; +} + + #pragma mark - iBean (Bean Collections) related storage methods - (NSArray*) getBeanCollections { diff --git a/iBean/iBean/Configuration.h b/iBean/iBean/Configuration.h index bb7b24c..3753bd6 100644 --- a/iBean/iBean/Configuration.h +++ b/iBean/iBean/Configuration.h @@ -2,7 +2,7 @@ // Configuration.h // iBean // -// Created by Eddie Ehlin on 2013-01-14. +// Created by Eddie Ehlin on 2013-01-27. // Copyright (c) 2013 Eddie Ehlin. All rights reserved. // @@ -12,6 +12,6 @@ @interface Configuration : NSManagedObject -@property (nonatomic, retain) NSNumber * instantExtractionTime; +@property (nonatomic, retain) NSNumber * instantExtractionTimer; @end diff --git a/iBean/iBean/Configuration.m b/iBean/iBean/Configuration.m index 6fde89e..cba131b 100644 --- a/iBean/iBean/Configuration.m +++ b/iBean/iBean/Configuration.m @@ -2,7 +2,7 @@ // Configuration.m // iBean // -// Created by Eddie Ehlin on 2013-01-14. +// Created by Eddie Ehlin on 2013-01-27. // Copyright (c) 2013 Eddie Ehlin. All rights reserved. // @@ -11,6 +11,6 @@ @implementation Configuration -@dynamic instantExtractionTime; +@dynamic instantExtractionTimer; @end diff --git a/iBean/iBean/InstantExtractionViewController.h b/iBean/iBean/InstantExtractionViewController.h index 92b265e..f988197 100644 --- a/iBean/iBean/InstantExtractionViewController.h +++ b/iBean/iBean/InstantExtractionViewController.h @@ -7,13 +7,11 @@ // #import -#import "Configuration+Interface.h" @interface InstantExtractionViewController : UIViewController @property (nonatomic, assign) double extractionProgress; @property (nonatomic, assign) BOOL extractionInProgress; -@property (nonatomic, strong) Configuration *configuration; /* Utility methods */ - (void) initViewController; diff --git a/iBean/iBean/InstantExtractionViewController.m b/iBean/iBean/InstantExtractionViewController.m index d0205c8..0ab0a9c 100644 --- a/iBean/iBean/InstantExtractionViewController.m +++ b/iBean/iBean/InstantExtractionViewController.m @@ -50,19 +50,10 @@ #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]]; + NSLog(@"Loading & setting stepper!"); + //Fetch extraction timer setting + NSNumber* extractionTimerSetting = [(AppDelegate*) [[UIApplication sharedApplication] delegate] getInstantExtractionTimer]; + [self.extractionSettingStepper setValue: extractionTimerSetting != nil ? [extractionTimerSetting doubleValue] : 0.0f]; [self updateExtractionSettingLabel]; } @@ -88,9 +79,6 @@ if ([(AppDelegate*) [[UIApplication sharedApplication] delegate] getTimer] != nil) { [(AppDelegate*) [[UIApplication sharedApplication] delegate] haltTimer:YES]; - - //Return UI to "Start extraction" state. - //[self timerInterrupted]; } } @@ -127,21 +115,15 @@ - (IBAction)setExtractionTimer:(id)sender { - if (self.configuration != nil) + NSError* error = [(AppDelegate*) [[UIApplication sharedApplication] delegate] setInstantExtractionTimer:[NSNumber numberWithDouble:self.extractionSettingStepper.value]]; + if (error != 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]; - } + 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]; diff --git a/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents b/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents index 98664e2..f89e12d 100644 --- a/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents +++ b/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents @@ -16,7 +16,7 @@ - + -- cgit v1.2.3