Permalink
Browse files

Add a boolean value to check if clock is started or not. If already s…

…tarted and start method called -> Not Restart Clock Animation
  • Loading branch information...
1 parent fd2244e commit dd480ea5345cdff834de8d22dceeb1385ea10607 Rousseau Quentin committed Mar 14, 2013
Showing with 12 additions and 6 deletions.
  1. +1 −0 AnalogClockWithImages/PSAnalogClockView.h
  2. +11 −6 AnalogClockWithImages/PSAnalogClockView.m
@@ -22,6 +22,7 @@ typedef enum {
@interface PSAnalogClockView : UIView
+@property (nonatomic) BOOL isStarted;
@property (nonatomic, strong) UIImage *secondHandImage;
@property (nonatomic, strong) UIImage *minuteHandImage;
@property (nonatomic, strong) UIImage *hourHandImage;
@@ -99,17 +99,22 @@ - (void)addImageViews
- (void)start
{
- self.clockUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
- target:self
- selector:@selector(updateClockTimeAnimated:)
- userInfo:nil
- repeats:YES];
- [self updateClockTimeAnimated:NO];
+ if(!isStarted)
+ {
+ self.clockUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
+ target:self
+ selector:@selector(updateClockTimeAnimated:)
+ userInfo:nil
+ repeats:YES];
+ [self updateClockTimeAnimated:NO];
+ isStarted = YES;
+ }
}
- (void)stop
{
[self.clockUpdateTimer invalidate]; self.clockUpdateTimer = nil;
+ isStarted = NO;
}
- (void)updateClockTimeAnimated:(BOOL)animated

0 comments on commit dd480ea

Please sign in to comment.