Permalink
Browse files

You can now update the the target date while the viewController anima…

…tes.
  • Loading branch information...
1 parent 68ff742 commit e1f63329bd4660ec67344e8fd7f6856720a19560 Hans Sjunnesson committed Sep 18, 2010
Showing with 29 additions and 4 deletions.
  1. +3 −0 Classes/HSAnimatedCalendarViewController.h
  2. +26 −4 Classes/HSAnimatedCalendarViewController.m
@@ -71,6 +71,9 @@
// Stops the animating timer
- (void)stopTimer;
+// Sets the target date to |targetDate|. Will automatically set the countdown mode.
+- (void)setTargetDate:(NSDate*)targetDate;
+
// Returns the specific CATtransition we use to transition between images.
@property (readonly) CATransition *calendarTransition;
@@ -88,11 +88,17 @@ - (void)updateDate {
int tenSeconds;
int seconds;
- BOOL isCountdown = [[configuration_ objectForKey:@"Countdown"] boolValue];
-
+ BOOL isCountdown = NO;
+ NSDate *target = nil;
+
+ @synchronized (configuration_) {
+ id temp = [configuration_ objectForKey:kCountdown];
+ if (temp)
+ isCountdown = [(NSNumber*)temp boolValue];
+ target = [configuration_ objectForKey:kCountdownDate];
+ }
+
if (isCountdown) {
- NSDate *target = [configuration_ objectForKey:@"CountdownDate"];
-
if (!target)
[NSException raise:@"NullPointerException" format:@"CountdownDate not defined in %@.plist", configPrefix_];
@@ -392,6 +398,22 @@ - (void)viewDidUnload {
}
#pragma mark -
+#pragma mark State accessors
+
+- (void)setTargetDate:(NSDate*)targetDate {
+ @synchronized (configuration_) {
+ NSMutableDictionary *d = [[NSMutableDictionary alloc] initWithDictionary:configuration_];
+
+ [d setValue:targetDate forKey:kCountdownDate];
+ [d setValue:[NSNumber numberWithInt:1] forKey:kCountdown];
+
+ id temp = configuration_;
+ configuration_ = d;
+ [temp release];
+ }
+}
+
+#pragma mark -
#pragma mark Timer methods
- (void)startTimer {

0 comments on commit e1f6332

Please sign in to comment.