Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Made didSelect: optional in the protocol (as it is unnecessary when b…

…locks are used)
  • Loading branch information...
commit cbfae94f993135471921f6247eb3185d376b371d 1 parent 10fad77
@jasonmorrissey authored
Showing with 13 additions and 4 deletions.
  1. +1 −1  JMSlider/JMSlider.h
  2. +12 −3 JMSlider/JMSlider.m
View
2  JMSlider/JMSlider.h
@@ -22,8 +22,8 @@ typedef void(^JMSliderExecutionBlock)(void);
#pragma Mark - JMSliderDelegate
@protocol JMSliderDelegate <NSObject>
--(void)slider:(JMSlider *)slider didSelect:(JMSliderSelection)selection;
@optional
+-(void)slider:(JMSlider *)slider didSelect:(JMSliderSelection)selection;
-(JMCenterView *)sliderCenterViewForSlider:(JMSlider *)slider;
-(JMSideView *)sliderLeftViewForSlider:(JMSlider *)slider;
-(JMSideView *)sliderRightViewForSlider:(JMSlider *)slider;
View
15 JMSlider/JMSlider.m
@@ -177,7 +177,10 @@ - (void)releaseDragShouldCancel:(BOOL)cancelled;
if (!self.suppressCallbacks && self.slideRatio < (-1. + kJMSliderOptionActivationMargin))
{
self.suppressCallbacks = YES;
- [self.delegate slider:self didSelect:JMSliderSelectionLeft];
+ if ([self.delegate respondsToSelector:@selector(slider:didSelect:)])
+ {
+ [self.delegate slider:self didSelect:JMSliderSelectionLeft];
+ }
#if NS_BLOCKS_AVAILABLE
if (leftExecuteBlock_) leftExecuteBlock_();
#endif
@@ -186,7 +189,10 @@ - (void)releaseDragShouldCancel:(BOOL)cancelled;
else if (!self.suppressCallbacks && self.slideRatio > (1. - kJMSliderOptionActivationMargin))
{
self.suppressCallbacks = YES;
- [self.delegate slider:self didSelect:JMSliderSelectionRight];
+ if ([self.delegate respondsToSelector:@selector(slider:didSelect:)])
+ {
+ [self.delegate slider:self didSelect:JMSliderSelectionRight];
+ }
#if NS_BLOCKS_AVAILABLE
if (rightExecuteBlock_) rightExecuteBlock_();
#endif
@@ -203,7 +209,10 @@ - (void)tappedCenterView;
{
if (fabs(self.slideRatio) < kJMSliderOptionActivationMargin)
{
- [self.delegate slider:self didSelect:JMSliderSelectionCenter];
+ if ([self.delegate respondsToSelector:@selector(slider:didSelect:)])
+ {
+ [self.delegate slider:self didSelect:JMSliderSelectionCenter];
+ }
#if NS_BLOCKS_AVAILABLE
if (centerExecuteBlock_) centerExecuteBlock_();
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.