diff options
author | Eddie Ehlin <eddiex@eddiex.se> | 2013-01-14 21:55:03 +0100 |
---|---|---|
committer | Eddie Ehlin <eddiex@eddiex.se> | 2013-01-14 21:55:03 +0100 |
commit | e2eb9397b85b1b6ec8a1b2b170f0d54f33f07f20 (patch) | |
tree | d2f09d1ef2582fe29a6f91c0333fcc8f1f35056e /iBean/iBean | |
parent | 0f4ee390a7d365e6b6fc8366b06d0f5a9fa58b3e (diff) | |
download | iBean-e2eb9397b85b1b6ec8a1b2b170f0d54f33f07f20.tar.gz iBean-e2eb9397b85b1b6ec8a1b2b170f0d54f33f07f20.zip |
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.
Diffstat (limited to 'iBean/iBean')
-rw-r--r-- | iBean/iBean/.DS_Store | bin | 6148 -> 6148 bytes | |||
-rw-r--r-- | iBean/iBean/AppDelegate+Storage.h | 6 | ||||
-rw-r--r-- | iBean/iBean/AppDelegate+Storage.m | 27 | ||||
-rw-r--r-- | iBean/iBean/Configuration+Interface.h | 13 | ||||
-rw-r--r-- | iBean/iBean/Configuration+Interface.m | 13 | ||||
-rw-r--r-- | iBean/iBean/Configuration.h | 17 | ||||
-rw-r--r-- | iBean/iBean/Configuration.m | 16 | ||||
-rw-r--r-- | iBean/iBean/InstaBeanConfiguration.h | 17 | ||||
-rw-r--r-- | iBean/iBean/InstaBeanConfiguration.m | 16 | ||||
-rw-r--r-- | iBean/iBean/InstantExtractionViewController.h (renamed from iBean/iBean/InstaBeanViewController.h) | 10 | ||||
-rw-r--r-- | iBean/iBean/InstantExtractionViewController.m (renamed from iBean/iBean/InstaBeanViewController.m) | 22 | ||||
-rw-r--r-- | iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents | 6 | ||||
-rw-r--r-- | iBean/iBean/iPhoneStoryboard.storyboard | 8 |
13 files changed, 105 insertions, 66 deletions
diff --git a/iBean/iBean/.DS_Store b/iBean/iBean/.DS_Store Binary files differindex 3be0f60..9578c17 100644 --- a/iBean/iBean/.DS_Store +++ b/iBean/iBean/.DS_Store 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 <Foundation/Foundation.h> +#import <CoreData/CoreData.h> + + +@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 <Foundation/Foundation.h> -#import <CoreData/CoreData.h> - - -@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/InstantExtractionViewController.h index f21c3bf..e8ec739 100644 --- a/iBean/iBean/InstaBeanViewController.h +++ b/iBean/iBean/InstantExtractionViewController.h @@ -1,5 +1,5 @@ // -// InstaBeanViewController.h +// InstantExtractionViewController.h // iBean // // Created by Eddie Ehlin on 2012-12-31. @@ -7,16 +7,16 @@ // #import <UIKit/UIKit.h> -#import "InstaBeanConfiguration.h" +#import "Configuration+Interface.h" -@interface InstaBeanViewController : UIViewController +@interface InstantExtractionViewController : UIViewController @property (nonatomic, assign) double extractionProgress; @property (nonatomic, strong) NSTimer* timer; -@property (nonatomic, strong) InstaBeanConfiguration *configuration; +@property (nonatomic, strong) Configuration *configuration; /* Utility methods */ -- (void) initInstaBean; +- (void) initViewController; - (void) updateExtractionSettingLabel; - (void) updateExtractionProgressLabel; - (void) haltExtractionTimer; diff --git a/iBean/iBean/InstaBeanViewController.m b/iBean/iBean/InstantExtractionViewController.m index 5d3d566..699d2c8 100644 --- a/iBean/iBean/InstaBeanViewController.m +++ b/iBean/iBean/InstantExtractionViewController.m @@ -1,19 +1,19 @@ // -// InstaBeanViewController.m +// InstantExtractionViewController.m // iBean // // Created by Eddie Ehlin on 2012-12-31. // Copyright (c) 2012 Eddie Ehlin. All rights reserved. // -#import "InstaBeanViewController.h" +#import "InstantExtractionViewController.h" #import "AppDelegate+Storage.h" -@interface InstaBeanViewController () +@interface InstantExtractionViewController () @end -@implementation InstaBeanViewController +@implementation InstantExtractionViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil @@ -34,7 +34,7 @@ - (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [self initInstaBean]; + [self initViewController]; } - (void)didReceiveMemoryWarning @@ -48,21 +48,21 @@ Utility methods *****************************************************/ #pragma mark - Utility methods -- (void) initInstaBean +- (void) initViewController { if (self.configuration == nil) { NSLog(@"Loading & setting stepper!"); - self.configuration = [(AppDelegate*) [[UIApplication sharedApplication] delegate] getInstaBeanConfiguration]; + self.configuration = [(AppDelegate*) [[UIApplication sharedApplication] delegate] getConfiguration]; if (self.configuration == nil) { - NSLog(@"initInstaBean received nil for configuration!"); + NSLog(@"InstantExtractionViewController - initViewController: received nil for configuration!"); return; } } - [self.extractionSettingStepper setValue:[self.configuration.extractionTime doubleValue]]; + [self.extractionSettingStepper setValue:[self.configuration.instantExtractionTime doubleValue]]; [self updateExtractionSettingLabel]; } @@ -122,13 +122,13 @@ if (self.configuration != nil) { - self.configuration.extractionTime = [NSNumber numberWithDouble:self.extractionSettingStepper.value]; + self.configuration.instantExtractionTime = [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!"); + NSLog(@"InstantExtraction unable to save configuration!"); UIAlertView *saveErrorAlert = [[UIAlertView alloc] initWithTitle:@"Save error!" message:@"Unable to save configuration." 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 @@ <attribute name="note" optional="YES" attributeType="String" syncable="YES"/> <relationship name="beans" optional="YES" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="Bean" inverseName="beanCollection" inverseEntity="Bean" syncable="YES"/> </entity> - <entity name="InstaBeanConfiguration" representedClassName="InstaBeanConfiguration" syncable="YES"> - <attribute name="extractionTime" optional="YES" attributeType="Double" defaultValueString="0.0" syncable="YES"/> + <entity name="Configuration" representedClassName="Configuration" syncable="YES"> + <attribute name="instantExtractionTime" optional="YES" attributeType="Double" defaultValueString="0.0" syncable="YES"/> </entity> <elements> <element name="Bean" positionX="-369" positionY="111" width="128" height="105"/> <element name="BeanCollection" positionX="160" positionY="192" width="128" height="150"/> - <element name="InstaBeanConfiguration" positionX="160" positionY="192" width="128" height="60"/> + <element name="Configuration" positionX="160" positionY="192" width="128" height="60"/> </elements> </model>
\ 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 @@ </objects> <point key="canvasLocation" x="1285" y="403"/> </scene> - <!--Insta Bean View Controller - Insta bean--> + <!--Instant Extraction View Controller - Insta bean--> <scene sceneID="Lvr-w4-t8a"> <objects> - <viewController id="b3D-qj-cdZ" customClass="InstaBeanViewController" sceneMemberID="viewController"> + <viewController id="b3D-qj-cdZ" customClass="InstantExtractionViewController" sceneMemberID="viewController"> <view key="view" contentMode="scaleToFill" id="NBj-4q-93f"> <rect key="frame" x="0.0" y="20" width="320" height="499"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> @@ -696,8 +696,8 @@ <relationship kind="outlet" name="extractionSettingStepper" candidateClass="UIStepper"/> </relationships> </class> - <class className="InstaBeanViewController" superclassName="UIViewController"> - <source key="sourceIdentifier" type="project" relativePath="./Classes/InstaBeanViewController.h"/> + <class className="InstantExtractionViewController" superclassName="UIViewController"> + <source key="sourceIdentifier" type="project" relativePath="./Classes/InstantExtractionViewController.h"/> <relationships> <relationship kind="action" name="setExtractionTimer:"/> <relationship kind="action" name="startExtraction:"/> |