Skip to content

Commit

Permalink
Use new typesafe enum macro. Run analyzer.
Browse files Browse the repository at this point in the history
This helps guarantee that all switch cases are properly handled.

Assumed that SVPullToRefreshStateAll should be treated the same as SVPullToRefreshStateStopped in existing switch statements, since SVPullToRefreshStateAll is an invalid state for those. assert(NO) would also be appropriate.

Turned on static analyzer since defining the SVPullToRefreshStateAll cases in existing switch statements fixed all analyzer warnings.
  • Loading branch information
Heath Borders committed May 20, 2013
1 parent 5b98a05 commit a0d347e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Demo/SVPullToRefreshDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
};
name = Debug;
Expand All @@ -278,6 +279,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
Expand Down
8 changes: 2 additions & 6 deletions SVPullToRefresh/UIScrollView+SVPullToRefresh.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@

@interface UIScrollView (SVPullToRefresh)

enum {
typedef NS_ENUM(NSUInteger, SVPullToRefreshPosition) {
SVPullToRefreshPositionTop = 0,
SVPullToRefreshPositionBottom,
};

typedef NSUInteger SVPullToRefreshPosition;

- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler;
- (void)addPullToRefreshWithActionHandler:(void (^)(void))actionHandler position:(SVPullToRefreshPosition)position;
- (void)triggerPullToRefresh;
Expand All @@ -32,15 +30,13 @@ typedef NSUInteger SVPullToRefreshPosition;
@end


enum {
typedef NS_ENUM(NSUInteger, SVPullToRefreshState) {
SVPullToRefreshStateStopped = 0,
SVPullToRefreshStateTriggered,
SVPullToRefreshStateLoading,
SVPullToRefreshStateAll = 10
};

typedef NSUInteger SVPullToRefreshState;

@interface SVPullToRefreshView : UIView

@property (nonatomic, strong) UIColor *arrowColor;
Expand Down
2 changes: 2 additions & 0 deletions SVPullToRefresh/UIScrollView+SVPullToRefresh.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ - (void)layoutSubviews {
}
else {
switch (self.state) {
case SVPullToRefreshStateAll:
case SVPullToRefreshStateStopped:
self.arrow.alpha = 1;
[self.activityIndicatorView stopAnimating];
Expand Down Expand Up @@ -623,6 +624,7 @@ - (void)setState:(SVPullToRefreshState)newState {
[self setNeedsLayout];

switch (newState) {
case SVPullToRefreshStateAll:
case SVPullToRefreshStateStopped:
[self resetScrollViewContentInset];
self.wasTriggeredByUser = YES;
Expand Down

0 comments on commit a0d347e

Please sign in to comment.