Permalink
Browse files

ARC

  • Loading branch information...
1 parent 83ea0bd commit e6e0fc72ca2c1bc2ffce305bb63b19fdda3e76b5 @coreyfloyd coreyfloyd committed Apr 18, 2012
Showing with 4 additions and 39 deletions.
  1. +2 −2 TimerScroller/TimeScroller.h
  2. +2 −37 TimerScroller/TimeScroller.m
@@ -28,7 +28,7 @@
@interface TimeScroller : UIImageView {
@protected
- id <TimeScrollerDelegate> _delegate;
+ id <TimeScrollerDelegate> __weak _delegate;
UITableView *_tableView;
UIImageView *_scrollBar;
UILabel *_timeLabel;
@@ -41,7 +41,7 @@
}
-@property (nonatomic, assign) id <TimeScrollerDelegate> delegate;
+@property (nonatomic, weak) id <TimeScrollerDelegate> delegate;
@property (nonatomic, copy) NSCalendar *calendar;
- (id)initWithDelegate:(id <TimeScrollerDelegate>)delegate;
@@ -57,26 +57,20 @@ - (id)initWithDelegate:(id<TimeScrollerDelegate>)delegate {
_backgroundView = [[UIImageView alloc] initWithImage:background];
_backgroundView.frame = CGRectMake(CGRectGetWidth(self.frame) - 80.0f, 0.0f, 80.0f, CGRectGetHeight(self.frame));
[self addSubview:_backgroundView];
- [_backgroundView release];
_handContainer = [[UIView alloc] initWithFrame:CGRectMake(5.0f, 4.0f, 20.0f, 20.0f)];
[_backgroundView addSubview:_handContainer];
_hourHand = [[UIView alloc] initWithFrame:CGRectMake(8.0f, 0.0f, 4.0f, 20.0f)];
UIImageView *hourImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"timescroll_hourhand"]];
[_hourHand addSubview:hourImageView];
- [hourImageView release];
[_handContainer addSubview:_hourHand];
- [_hourHand release];
_minuteHand = [[UIView alloc] initWithFrame:CGRectMake(8.0f, 0.0f, 4.0f, 20.0f)];
UIImageView *minuteImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"timescroll_minutehand"]];
[_minuteHand addSubview:minuteImageView];
- [minuteImageView release];
[_handContainer addSubview:_minuteHand];
- [_minuteHand release];
- [_handContainer release];
_timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(30.0f, 4.0f, 50.0f, 20.0f)];
_timeLabel.textColor = [UIColor whiteColor];
@@ -86,7 +80,6 @@ - (id)initWithDelegate:(id<TimeScrollerDelegate>)delegate {
_timeLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:9.0f];
_timeLabel.autoresizingMask = UIViewAutoresizingNone;
[_backgroundView addSubview:_timeLabel];
- [_timeLabel release];
_dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(30.0f, 9.0f, 100.0f, 20.0f)];
_dateLabel.textColor = [UIColor colorWithRed:179.0f green:179.0f blue:179.0f alpha:0.60f];
@@ -97,7 +90,6 @@ - (id)initWithDelegate:(id<TimeScrollerDelegate>)delegate {
_dateLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:9.0f];
_dateLabel.alpha = 0.0f;
[_backgroundView addSubview:_dateLabel];
- [_dateLabel release];
_delegate = delegate;
@@ -113,62 +105,36 @@ - (void)createFormatters{
[dateFormatter setTimeZone:self.calendar.timeZone];
[dateFormatter setDateFormat:@"h:mm a"];
self.timeDateFormatter = dateFormatter;
- [dateFormatter release];
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setCalendar:self.calendar];
[dateFormatter setTimeZone:self.calendar.timeZone];
dateFormatter.dateFormat = @"cccc";
self.dayOfWeekDateFormatter = dateFormatter;
- [dateFormatter release];
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setCalendar:self.calendar];
[dateFormatter setTimeZone:self.calendar.timeZone];
dateFormatter.dateFormat = @"MMMM d";
self.monthDayDateFormatter = dateFormatter;
- [dateFormatter release];
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setCalendar:self.calendar];
[dateFormatter setTimeZone:self.calendar.timeZone];
dateFormatter.dateFormat = @"MMMM d, yyyy";
self.monthDayYearDateFormatter = dateFormatter;
- [dateFormatter release];
}
- (void)setCalendar:(NSCalendar *)cal{
- [cal retain];
- [_calendar autorelease];
_calendar = cal;
[self createFormatters];
}
-- (void)dealloc {
-
- [_calendar release];
- _calendar = nil;
-
- [_dayOfWeekDateFormatter release];
- _dayOfWeekDateFormatter = nil;
- [_monthDayDateFormatter release];
- _monthDayDateFormatter = nil;
- [_monthDayYearDateFormatter release];
- _monthDayYearDateFormatter = nil;
-
- [_dateFormattter release];
- _dateFormattter = nil;
-
- [_lastDate release];
-
- [super dealloc];
-
-}
- (void)captureTableViewAndScrollBar {
@@ -342,11 +308,10 @@ - (void)updateDisplayWithCell:(UITableViewCell *)cell {
if (_lastDate) {
- [_lastDate release];
_lastDate = nil;
}
- _lastDate = [date retain];
+ _lastDate = date;
CGRect backgroundFrame = _backgroundView.frame;
@@ -444,7 +409,7 @@ - (void)scrollViewDidScroll {
CGPoint point = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
point = [_scrollBar convertPoint:point toView:_tableView];
- UIView *view = [_tableView hitTest:point withEvent:UIEventTypeTouches];
+ UIView *view = [_tableView hitTest:point withEvent:nil];
if ([view.superview isKindOfClass:[UITableViewCell class]]) {

0 comments on commit e6e0fc7

Please sign in to comment.