aboutsummaryrefslogtreecommitdiffstats
path: root/iBean
diff options
context:
space:
mode:
Diffstat (limited to 'iBean')
-rw-r--r--iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstatebin36973 -> 37321 bytes
-rw-r--r--iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist54
-rw-r--r--iBean/iBean/AppDelegate+Storage.h5
-rw-r--r--iBean/iBean/AppDelegate+Storage.m41
-rw-r--r--iBean/iBean/AppDelegate.h3
-rw-r--r--iBean/iBean/InstantExtractionViewController.h2
-rw-r--r--iBean/iBean/InstantExtractionViewController.m22
7 files changed, 118 insertions, 9 deletions
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 863f4fe..7208623 100644
--- a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate
+++ b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate
Binary files differ
diff --git a/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
index 05301bc..e8320d9 100644
--- a/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
+++ b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
@@ -2,4 +2,58 @@
<Bucket
type = "1"
version = "1.0">
+ <FileBreakpoints>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "iBean/InstantExtractionViewController.m"
+ timestampString = "380496617.591403"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "113"
+ endingLineNumber = "113"
+ landmarkName = "-startExtraction:"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "iBean/InstantExtractionViewController.m"
+ timestampString = "380494622.652202"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "88"
+ endingLineNumber = "88"
+ landmarkName = "-haltExtractionTimer"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "iBean/InstantExtractionViewController.m"
+ timestampString = "380496617.591403"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "99"
+ endingLineNumber = "99"
+ landmarkName = "-timerInterrupted"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "iBean/AppDelegate+Storage.m"
+ timestampString = "380496246.739132"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "164"
+ endingLineNumber = "164"
+ landmarkName = "-createTimer::::"
+ landmarkType = "5">
+ </FileBreakpoint>
+ </FileBreakpoints>
</Bucket>
diff --git a/iBean/iBean/AppDelegate+Storage.h b/iBean/iBean/AppDelegate+Storage.h
index bec63e0..f444572 100644
--- a/iBean/iBean/AppDelegate+Storage.h
+++ b/iBean/iBean/AppDelegate+Storage.h
@@ -33,4 +33,9 @@
- (BeanCollection*) createBeanCollection;
- (Bean*) createBean;
+#pragma mark - iBean timer methods
+- (NSTimer*) getTimer;
+- (NSTimer*) createTimer:(id) callbackTarget: (SEL) selector: (id)userInfo: (BOOL)repeats;
+- (void) haltTimer: (BOOL)interrupt;
+
@end
diff --git a/iBean/iBean/AppDelegate+Storage.m b/iBean/iBean/AppDelegate+Storage.m
index 5668bd5..4532397 100644
--- a/iBean/iBean/AppDelegate+Storage.m
+++ b/iBean/iBean/AppDelegate+Storage.m
@@ -153,6 +153,47 @@
return b;
}
+#pragma mark - iBean timer related methods
+- (NSTimer*) getTimer
+{
+ return self.timer;
+}
+
+- (NSTimer*) createTimer:(id) callbackTarget: (SEL) selector: (id)userInfo: (BOOL)repeats
+{
+ if (self.timer != nil)
+ {
+ BOOL interruptCallbackTarget = self.timerCallbackTarget != callbackTarget;
+ [self haltTimer: interruptCallbackTarget];
+ }
+
+ self.timerCallbackTarget = callbackTarget;
+ self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1f target:callbackTarget selector:selector userInfo:userInfo repeats:repeats];
+
+ return self.timer;
+}
+
+
+- (void) haltTimer: (BOOL) interrupt
+{
+ if (self.timer != nil)
+ {
+ [self.timer invalidate];
+ self.timer = nil;
+
+ if (self.timerCallbackTarget != nil && interrupt == YES)
+ {
+ //Must call the target to notify that it's timer has been interrupted...
+ //First we must make sure that target has implemented timerInterrupted method.
+ if ([self.timerCallbackTarget respondsToSelector:@selector(timerInterrupted)])
+ {
+ [self.timerCallbackTarget performSelector:@selector(timerInterrupted)];
+ }
+ }
+ }
+}
+
+
@end
diff --git a/iBean/iBean/AppDelegate.h b/iBean/iBean/AppDelegate.h
index 40084d5..b09db3e 100644
--- a/iBean/iBean/AppDelegate.h
+++ b/iBean/iBean/AppDelegate.h
@@ -12,6 +12,9 @@
@property (strong, nonatomic) UIWindow *window;
+@property (nonatomic, strong) id timerCallbackTarget;
+@property (nonatomic, strong) NSTimer *timer;
+
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
diff --git a/iBean/iBean/InstantExtractionViewController.h b/iBean/iBean/InstantExtractionViewController.h
index e8ec739..4fded92 100644
--- a/iBean/iBean/InstantExtractionViewController.h
+++ b/iBean/iBean/InstantExtractionViewController.h
@@ -12,7 +12,6 @@
@interface InstantExtractionViewController : UIViewController
@property (nonatomic, assign) double extractionProgress;
-@property (nonatomic, strong) NSTimer* timer;
@property (nonatomic, strong) Configuration *configuration;
/* Utility methods */
@@ -20,6 +19,7 @@
- (void) updateExtractionSettingLabel;
- (void) updateExtractionProgressLabel;
- (void) haltExtractionTimer;
+- (void) timerInterrupted;
/* UI Outlets */
@property (weak, nonatomic) IBOutlet UILabel *extractionSettingLabel;
diff --git a/iBean/iBean/InstantExtractionViewController.m b/iBean/iBean/InstantExtractionViewController.m
index 699d2c8..3c53faa 100644
--- a/iBean/iBean/InstantExtractionViewController.m
+++ b/iBean/iBean/InstantExtractionViewController.m
@@ -85,17 +85,24 @@
- (void) haltExtractionTimer
{
- if (self.timer != nil)
+ if ([(AppDelegate*) [[UIApplication sharedApplication] delegate] getTimer] != nil)
{
- [self.timer invalidate];
- self.timer = nil;
+ [(AppDelegate*) [[UIApplication sharedApplication] delegate] haltTimer:NO];
//Return UI to "Start extraction" state.
- [self.extractionButton setTitle:@"Start extraction" forState:UIControlStateNormal];
- [self.extractionSettingStepper setEnabled:YES];
+ [self timerInterrupted];
}
}
+- (void) timerInterrupted
+{
+ NSLog(@"InstantExtractionViewController - timerInterrupted");
+
+ //Return UI to "Start extraction" state.
+ [self.extractionButton setTitle:@"Start extraction" forState:UIControlStateNormal];
+ [self.extractionSettingStepper setEnabled:YES];
+}
+
/*****************************************************
UI Actions
*****************************************************/
@@ -103,14 +110,13 @@
- (IBAction)startExtraction:(id)sender {
//Extraction in progress?
- if (self.timer == nil)
+ if ([(AppDelegate*) [[UIApplication sharedApplication] delegate] getTimer] == 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];
-
+ [(AppDelegate*) [[UIApplication sharedApplication] delegate] createTimer:self :@selector(updateExtractionProgressLabel) :nil :YES];
}
else
{