Skip to content

Commit

Permalink
Merge pull request #50 from jklp/master
Browse files Browse the repository at this point in the history
Fix for UIDatePickerModeCountDownTimer callback
  • Loading branch information
skywinder committed Sep 29, 2014
2 parents bb4add3 + 7e2b505 commit ba8aee3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Pickers/ActionSheetDatePicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
@interface ActionSheetDatePicker()
@property (nonatomic, assign) UIDatePickerMode datePickerMode;
@property (nonatomic, strong) NSDate *selectedDate;
@property (nonatomic, assign) NSTimeInterval duration;
@end

@implementation ActionSheetDatePicker
@synthesize selectedDate = _selectedDate;
@synthesize datePickerMode = _datePickerMode;
@synthesize duration = _duration;

+ (id)showPickerWithTitle:(NSString *)title
datePickerMode:(UIDatePickerMode)datePickerMode selectedDate:(NSDate *)selectedDate
Expand Down Expand Up @@ -77,6 +79,7 @@ - (id)initWithTitle:(NSString *)title datePickerMode:(UIDatePickerMode)datePicke
self.title = title;
self.datePickerMode = datePickerMode;
self.selectedDate = selectedDate;
self.duration = 60;
}
return self;
}
Expand Down Expand Up @@ -126,7 +129,11 @@ - (void)notifyTarget:(id)target didSucceedWithAction:(SEL)action origin:(id)orig
else if ([target respondsToSelector:action])
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[target performSelector:action withObject:self.selectedDate withObject:origin];
if (self.datePickerMode == UIDatePickerModeCountDownTimer) {
[target performSelector:action withObject:@(self.duration) withObject:origin];
} else {
[target performSelector:action withObject:self.selectedDate withObject:origin];
}
#pragma clang diagnostic pop
else
NSAssert(NO, @"Invalid target/action ( %s / %s ) combination used for ActionSheetPicker", object_getClassName(target), sel_getName(action));
Expand Down Expand Up @@ -155,6 +162,7 @@ - (void)eventForDatePicker:(id)sender
return;
UIDatePicker *datePicker = (UIDatePicker *)sender;
self.selectedDate = datePicker.date;
self.duration = datePicker.countDownDuration;
}

- (void)customButtonPressed:(id)sender {
Expand Down

0 comments on commit ba8aee3

Please sign in to comment.