Browse files

Change to ARC

  • Loading branch information...
1 parent 743679f commit b86128d6657e0536ea4db9b12ac343636ad2a2e1 Ninevillage committed Sep 20, 2012
View
7 Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.h
@@ -34,9 +34,10 @@ typedef enum{
} EGOPullRefreshState;
@protocol EGORefreshTableHeaderDelegate;
+
@interface EGORefreshTableHeaderView : UIView {
- id _delegate;
+ id delegate;
EGOPullRefreshState _state;
UILabel *_lastUpdatedLabel;
@@ -49,13 +50,15 @@ typedef enum{
@property(nonatomic,assign) id <EGORefreshTableHeaderDelegate> delegate;
+- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor;
+
- (void)refreshLastUpdatedDate;
- (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView;
- (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView;
- (void)egoRefreshScrollViewDataSourceDidFinishedLoading:(UIScrollView *)scrollView;
@end
-@protocol EGORefreshTableHeaderDelegate
+@protocol EGORefreshTableHeaderDelegate
- (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view;
- (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view;
@optional
View
47 Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.m
@@ -37,43 +37,40 @@ - (void)setState:(EGOPullRefreshState)aState;
@implementation EGORefreshTableHeaderView
-@synthesize delegate=_delegate;
+@synthesize delegate = _delegate;
-
-- (id)initWithFrame:(CGRect)frame {
- if (self = [super initWithFrame:frame]) {
+- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor {
+ if((self = [super initWithFrame:frame])) {
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.backgroundColor = [UIColor colorWithRed:226.0/255.0 green:231.0/255.0 blue:237.0/255.0 alpha:1.0];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 30.0f, self.frame.size.width, 20.0f)];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
label.font = [UIFont systemFontOfSize:12.0f];
- label.textColor = TEXT_COLOR;
+ label.textColor = textColor;
label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f];
label.shadowOffset = CGSizeMake(0.0f, 1.0f);
label.backgroundColor = [UIColor clearColor];
label.textAlignment = UITextAlignmentCenter;
[self addSubview:label];
_lastUpdatedLabel=label;
- [label release];
label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 48.0f, self.frame.size.width, 20.0f)];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
label.font = [UIFont boldSystemFontOfSize:13.0f];
- label.textColor = TEXT_COLOR;
+ label.textColor = textColor;
label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f];
label.shadowOffset = CGSizeMake(0.0f, 1.0f);
label.backgroundColor = [UIColor clearColor];
label.textAlignment = UITextAlignmentCenter;
[self addSubview:label];
_statusLabel=label;
- [label release];
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(25.0f, frame.size.height - 65.0f, 30.0f, 55.0f);
layer.contentsGravity = kCAGravityResizeAspect;
- layer.contents = (id)[UIImage imageNamed:@"blueArrow.png"].CGImage;
+ layer.contents = (id)[UIImage imageNamed:arrow].CGImage;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
@@ -88,7 +85,6 @@ - (id)initWithFrame:(CGRect)frame {
view.frame = CGRectMake(25.0f, frame.size.height - 38.0f, 20.0f, 20.0f);
[self addSubview:view];
_activityView = view;
- [view release];
[self setState:EGOOPullRefreshNormal];
@@ -99,24 +95,27 @@ - (id)initWithFrame:(CGRect)frame {
}
+- (id)initWithFrame:(CGRect)frame {
+ return [self initWithFrame:frame arrowImageName:@"blueArrow.png" textColor:TEXT_COLOR];
+}
#pragma mark -
#pragma mark Setters
- (void)refreshLastUpdatedDate {
-
- if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceLastUpdated:)]) {
+
+ if ([(NSObject*)self.delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceLastUpdated:)]) {
- NSDate *date = [_delegate egoRefreshTableHeaderDataSourceLastUpdated:self];
+ NSDate *date = [self.delegate egoRefreshTableHeaderDataSourceLastUpdated:self];
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setAMSymbol:@"AM"];
- [formatter setPMSymbol:@"PM"];
- [formatter setDateFormat:@"MM/dd/yyyy hh:mm:a"];
- _lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [formatter stringFromDate:date]];
+ [NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehaviorDefault];
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+ [dateFormatter setDateStyle:NSDateFormatterShortStyle];
+ [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
+
+ _lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [dateFormatter stringFromDate:date]];
[[NSUserDefaults standardUserDefaults] setObject:_lastUpdatedLabel.text forKey:@"EGORefreshTableView_LastRefresh"];
[[NSUserDefaults standardUserDefaults] synchronize];
- [formatter release];
} else {
@@ -190,7 +189,7 @@ - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView {
} else if (scrollView.isDragging) {
BOOL _loading = NO;
- if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) {
+ if ([(NSObject*)self.delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) {
_loading = [_delegate egoRefreshTableHeaderDataSourceIsLoading:self];
}
@@ -211,13 +210,14 @@ - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView {
- (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView {
BOOL _loading = NO;
- if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) {
+ if ([(NSObject*)self.delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) {
_loading = [_delegate egoRefreshTableHeaderDataSourceIsLoading:self];
}
if (scrollView.contentOffset.y <= - 65.0f && !_loading) {
-
- if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDidTriggerRefresh:)]) {
+ NSLog(@"hah");
+ if ([(NSObject*)self.delegate respondsToSelector:@selector(egoRefreshTableHeaderDidTriggerRefresh:)]) {
+ NSLog(@"huh");
[_delegate egoRefreshTableHeaderDidTriggerRefresh:self];
}
@@ -253,7 +253,6 @@ - (void)dealloc {
_statusLabel = nil;
_arrowImage = nil;
_lastUpdatedLabel = nil;
- [super dealloc];
}
View
5 EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h
@@ -34,9 +34,10 @@ typedef enum{
} EGOPullRefreshState;
@protocol EGORefreshTableHeaderDelegate;
+
@interface EGORefreshTableHeaderView : UIView {
- id _delegate;
+ id delegate;
EGOPullRefreshState _state;
UILabel *_lastUpdatedLabel;
@@ -57,7 +58,7 @@ typedef enum{
- (void)egoRefreshScrollViewDataSourceDidFinishedLoading:(UIScrollView *)scrollView;
@end
-@protocol EGORefreshTableHeaderDelegate
+@protocol EGORefreshTableHeaderDelegate
- (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view;
- (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view;
@optional
View
24 EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m
@@ -37,8 +37,7 @@ - (void)setState:(EGOPullRefreshState)aState;
@implementation EGORefreshTableHeaderView
-@synthesize delegate=_delegate;
-
+@synthesize delegate = _delegate;
- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor {
if((self = [super initWithFrame:frame])) {
@@ -56,7 +55,6 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI
label.textAlignment = UITextAlignmentCenter;
[self addSubview:label];
_lastUpdatedLabel=label;
- [label release];
label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 48.0f, self.frame.size.width, 20.0f)];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
@@ -68,7 +66,6 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI
label.textAlignment = UITextAlignmentCenter;
[self addSubview:label];
_statusLabel=label;
- [label release];
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(25.0f, frame.size.height - 65.0f, 30.0f, 55.0f);
@@ -88,7 +85,6 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI
view.frame = CGRectMake(25.0f, frame.size.height - 38.0f, 20.0f, 20.0f);
[self addSubview:view];
_activityView = view;
- [view release];
[self setState:EGOOPullRefreshNormal];
@@ -107,13 +103,13 @@ - (id)initWithFrame:(CGRect)frame {
#pragma mark Setters
- (void)refreshLastUpdatedDate {
-
- if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceLastUpdated:)]) {
+
+ if ([(NSObject*)self.delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceLastUpdated:)]) {
- NSDate *date = [_delegate egoRefreshTableHeaderDataSourceLastUpdated:self];
+ NSDate *date = [self.delegate egoRefreshTableHeaderDataSourceLastUpdated:self];
[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehaviorDefault];
- NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
@@ -193,7 +189,7 @@ - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView {
} else if (scrollView.isDragging) {
BOOL _loading = NO;
- if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) {
+ if ([(NSObject*)self.delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) {
_loading = [_delegate egoRefreshTableHeaderDataSourceIsLoading:self];
}
@@ -214,13 +210,14 @@ - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView {
- (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView {
BOOL _loading = NO;
- if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) {
+ if ([(NSObject*)self.delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) {
_loading = [_delegate egoRefreshTableHeaderDataSourceIsLoading:self];
}
if (scrollView.contentOffset.y <= - 65.0f && !_loading) {
-
- if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDidTriggerRefresh:)]) {
+ NSLog(@"hah");
+ if ([(NSObject*)self.delegate respondsToSelector:@selector(egoRefreshTableHeaderDidTriggerRefresh:)]) {
+ NSLog(@"huh");
[_delegate egoRefreshTableHeaderDidTriggerRefresh:self];
}
@@ -256,7 +253,6 @@ - (void)dealloc {
_statusLabel = nil;
_arrowImage = nil;
_lastUpdatedLabel = nil;
- [super dealloc];
}

0 comments on commit b86128d

Please sign in to comment.