aboutsummaryrefslogtreecommitdiffstats
path: root/iBean/iBean
diff options
context:
space:
mode:
authorEddie Ehlin <eddiex@eddiex.se>2013-01-27 12:46:33 +0100
committerEddie Ehlin <eddiex@eddiex.se>2013-01-27 12:46:33 +0100
commite3f505842ceba21ae0d58886d7424162bbf395d4 (patch)
treeeadb377c822cce6b47c3ee3198b4b8c24865a06f /iBean/iBean
parentc0120a7416208d34d8303b985bcdc78a5ffa16a1 (diff)
downloadiBean-e3f505842ceba21ae0d58886d7424162bbf395d4.tar.gz
iBean-e3f505842ceba21ae0d58886d7424162bbf395d4.zip
Minor cleanup made to Instant Extraction. No explicit use of configuration object at any view controller - all changes/reads are done via storage methods.
Diffstat (limited to 'iBean/iBean')
-rw-r--r--iBean/iBean/AppDelegate+Storage.h13
-rw-r--r--iBean/iBean/AppDelegate+Storage.m30
-rw-r--r--iBean/iBean/Configuration.h4
-rw-r--r--iBean/iBean/Configuration.m4
-rw-r--r--iBean/iBean/InstantExtractionViewController.h2
-rw-r--r--iBean/iBean/InstantExtractionViewController.m42
-rw-r--r--iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents2
7 files changed, 58 insertions, 39 deletions
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 <UIKit/UIKit.h>
-#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 @@
<relationship name="beans" optional="YES" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="Bean" inverseName="beanCollection" inverseEntity="Bean" syncable="YES"/>
</entity>
<entity name="Configuration" representedClassName="Configuration" syncable="YES">
- <attribute name="instantExtractionTime" optional="YES" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
+ <attribute name="instantExtractionTimer" optional="YES" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
</entity>
<elements>
<element name="Bean" positionX="-369" positionY="111" width="128" height="105"/>