Skip to content

Commit

Permalink
Removed dead code and did a little cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
klazuka committed Jan 3, 2010
1 parent 87369f6 commit eb0cdd8
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 87 deletions.
6 changes: 0 additions & 6 deletions Kal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
53D9F89010DD9CEE00759172 /* KalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D9F87510DD9CEE00759172 /* KalView.m */; };
53D9F89110DD9CEE00759172 /* KalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D9F87710DD9CEE00759172 /* KalViewController.m */; };
53D9F89710DD9CEE00759172 /* NSDateAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D9F87E10DD9CEE00759172 /* NSDateAdditions.m */; };
53D9F89810DD9CEE00759172 /* NSMutableArrayAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D9F88010DD9CEE00759172 /* NSMutableArrayAdditions.m */; };
53D9F89F10DD9CEE00759172 /* UIViewAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D9F88910DD9CEE00759172 /* UIViewAdditions.m */; };
53D9F8AE10DD9D9D00759172 /* HolidayAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D9F8AC10DD9D9D00759172 /* HolidayAppDelegate.m */; };
53D9F95F10DFC21D00759172 /* kal_grid_background.png in Resources */ = {isa = PBXBuildFile; fileRef = 53D9F95310DFC21D00759172 /* kal_grid_background.png */; };
Expand Down Expand Up @@ -109,8 +108,6 @@
53D9F87710DD9CEE00759172 /* KalViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KalViewController.m; sourceTree = "<group>"; };
53D9F87D10DD9CEE00759172 /* NSDateAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSDateAdditions.h; sourceTree = "<group>"; };
53D9F87E10DD9CEE00759172 /* NSDateAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSDateAdditions.m; sourceTree = "<group>"; };
53D9F87F10DD9CEE00759172 /* NSMutableArrayAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSMutableArrayAdditions.h; sourceTree = "<group>"; };
53D9F88010DD9CEE00759172 /* NSMutableArrayAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSMutableArrayAdditions.m; sourceTree = "<group>"; };
53D9F88810DD9CEE00759172 /* UIViewAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIViewAdditions.h; sourceTree = "<group>"; };
53D9F88910DD9CEE00759172 /* UIViewAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIViewAdditions.m; sourceTree = "<group>"; };
53D9F8A910DD9D9D00759172 /* Holiday_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Holiday_Prefix.pch; sourceTree = "<group>"; };
Expand Down Expand Up @@ -252,8 +249,6 @@
children = (
53D9F87D10DD9CEE00759172 /* NSDateAdditions.h */,
53D9F87E10DD9CEE00759172 /* NSDateAdditions.m */,
53D9F87F10DD9CEE00759172 /* NSMutableArrayAdditions.h */,
53D9F88010DD9CEE00759172 /* NSMutableArrayAdditions.m */,
53D9F88810DD9CEE00759172 /* UIViewAdditions.h */,
53D9F88910DD9CEE00759172 /* UIViewAdditions.m */,
);
Expand Down Expand Up @@ -361,7 +356,6 @@
53D9F89010DD9CEE00759172 /* KalView.m in Sources */,
53D9F89110DD9CEE00759172 /* KalViewController.m in Sources */,
53D9F89710DD9CEE00759172 /* NSDateAdditions.m in Sources */,
53D9F89810DD9CEE00759172 /* NSMutableArrayAdditions.m in Sources */,
53D9F89F10DD9CEE00759172 /* UIViewAdditions.m in Sources */,
53D9F8AE10DD9D9D00759172 /* HolidayAppDelegate.m in Sources */,
5387B4A310E902EF0011C4BA /* KalMonthView.m in Sources */,
Expand Down
6 changes: 5 additions & 1 deletion Kal/KalDate.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ - (unsigned int)year { return a.year; }

- (NSDate *)NSDate
{
return [NSDate cc_dateForDay:a.day month:a.month year:a.year];
NSDateComponents *c = [[[NSDateComponents alloc] init] autorelease];
c.day = a.day;
c.month = a.month;
c.year = a.year;
return [[NSCalendar currentCalendar] dateFromComponents:c];
}

- (BOOL)isToday { return [self isEqual:today]; }
Expand Down
4 changes: 2 additions & 2 deletions Kal/KalGridView.m
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ - (void)slide:(int)direction
// that is sliding offscreen.

[backMonthView showDates:[logic daysInSelectedMonth]
beginShared:[logic daysInFinalWeekOfPreviousMonth]
endShared:[logic daysInFirstWeekOfFollowingMonth]];
leadingAdjacentDates:[logic daysInFinalWeekOfPreviousMonth]
trailingAdjacentDates:[logic daysInFirstWeekOfFollowingMonth]];

BOOL keepOneRow = (direction == SLIDE_UP && [[logic daysInFinalWeekOfPreviousMonth] count] > 0)
|| (direction == SLIDE_DOWN && [[logic daysInFirstWeekOfFollowingMonth] count] > 0);
Expand Down
4 changes: 2 additions & 2 deletions Kal/KalLogic.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ + (NSSet *)keyPathsForValuesAffectingSelectedMonthNameAndYear
- (id)init
{
if ((self = [super init])) {
self.baseDate = [[NSDate cc_today] cc_dateByMovingToFirstDayOfTheMonth];
self.baseDate = [[NSDate date] cc_dateByMovingToFirstDayOfTheMonth];
monthAndYearFormatter = [[NSDateFormatter alloc] init];
[monthAndYearFormatter setDateFormat:@"MMMM yyyy"];
}
Expand All @@ -43,7 +43,7 @@ - (void)advanceToFollowingMonth

- (void)moveToTodaysMonth
{
self.baseDate = [[NSDate cc_today] cc_dateByMovingToFirstDayOfTheMonth];
self.baseDate = [[NSDate date] cc_dateByMovingToFirstDayOfTheMonth];
}

- (NSArray *)daysInFinalWeekOfPreviousMonth
Expand Down
2 changes: 1 addition & 1 deletion Kal/KalMonthView.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@property (nonatomic) NSUInteger numWeeks;

- (id)initWithFrame:(CGRect)rect; // designated initializer
- (void)showDates:(NSArray *)mainDates beginShared:(NSArray *)firstWeekShared endShared:(NSArray *)finalWeekShared;
- (void)showDates:(NSArray *)mainDates leadingAdjacentDates:(NSArray *)leadingAdjacentDates trailingAdjacentDates:(NSArray *)trailingAdjacentDates;
- (KalTileView *)todaysTileIfVisible;
- (KalTileView *)firstTileOfMonth;
- (KalTileView *)tileForDate:(KalDate *)date;
Expand Down
10 changes: 5 additions & 5 deletions Kal/KalMonthView.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ - (id)initWithFrame:(CGRect)frame
return self;
}

- (void)showDates:(NSArray *)mainDates beginShared:(NSArray *)firstWeekShared endShared:(NSArray *)finalWeekShared
- (void)showDates:(NSArray *)mainDates leadingAdjacentDates:(NSArray *)leadingAdjacentDates trailingAdjacentDates:(NSArray *)trailingAdjacentDates
{
int i = 0;

self.fromDate = [firstWeekShared count] > 0 ? [firstWeekShared objectAtIndex:0] : [mainDates objectAtIndex:0];
self.toDate = [finalWeekShared count] > 0 ? [finalWeekShared lastObject] : [mainDates lastObject];
self.fromDate = [leadingAdjacentDates count] > 0 ? [leadingAdjacentDates objectAtIndex:0] : [mainDates objectAtIndex:0];
self.toDate = [trailingAdjacentDates count] > 0 ? [trailingAdjacentDates lastObject] : [mainDates lastObject];

for (KalDate *d in firstWeekShared) {
for (KalDate *d in leadingAdjacentDates) {
KalTileView *tile = [self.subviews objectAtIndex:i];
[tile resetState];
tile.type = KalTileTypeAdjacent;
Expand All @@ -56,7 +56,7 @@ - (void)showDates:(NSArray *)mainDates beginShared:(NSArray *)firstWeekShared en
i++;
}

for (KalDate *d in finalWeekShared) {
for (KalDate *d in trailingAdjacentDates) {
KalTileView *tile = [self.subviews objectAtIndex:i];
[tile resetState];
tile.type = KalTileTypeAdjacent;
Expand Down
1 change: 0 additions & 1 deletion Kal/KalPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@

#import "UIViewAdditions.h"
#import "NSDateAdditions.h"
#import "NSMutableArrayAdditions.h"

6 changes: 0 additions & 6 deletions Kal/NSDateAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@
// All of the following methods use [NSCalendar currentCalendar] to perform
// their calculations.

+ (NSDate *)cc_today;
+ (NSDate *)cc_dateForDay:(NSUInteger)day month:(NSUInteger)month year:(NSUInteger)year;

- (BOOL)cc_isToday;
- (NSDate *)cc_dateByMovingToBeginningOfDay;
- (NSDate *)cc_dateByMovingToEndOfDay;
- (NSDate *)cc_dateByMovingToFirstDayOfTheMonth;
- (NSDate *)cc_dateByMovingToFirstDayOfThePreviousMonth;
- (NSDate *)cc_dateByMovingToFirstDayOfTheFollowingMonth;
- (NSDateComponents *)cc_componentsForMonthDayAndYear;
- (NSUInteger)cc_day;
- (NSUInteger)cc_weekday;
- (NSUInteger)cc_numberOfDaysInMonth;


@end
26 changes: 0 additions & 26 deletions Kal/NSDateAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,6 @@

@implementation NSDate (KalAdditions)

+ (NSDate *)cc_today { return [NSDate date]; }

+ (NSDate *)cc_dateForDay:(NSUInteger)day month:(NSUInteger)month year:(NSUInteger)year
{
NSDateComponents *c = [[[NSDateComponents alloc] init] autorelease];
c.day = day;
c.month = month;
c.year = year;
return [[NSCalendar currentCalendar] dateFromComponents:c];
}

- (BOOL)cc_isToday
{
// Performance optimization because [NSCalendar components:fromDate:] is expensive.
// (I verified this with Shark)
if (ABS([self timeIntervalSinceDate:[NSDate date]]) > 86400)
return NO;

return [self cc_day] == [[NSDate cc_today] cc_day];
}

- (NSDate *)cc_dateByMovingToBeginningOfDay
{
unsigned int flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
Expand Down Expand Up @@ -75,11 +54,6 @@ - (NSDateComponents *)cc_componentsForMonthDayAndYear
return [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:self];
}

- (NSUInteger)cc_day
{
return (NSUInteger)[[[NSCalendar currentCalendar] components:NSDayCalendarUnit fromDate:self] day];
}

- (NSUInteger)cc_weekday
{
return [[NSCalendar currentCalendar] ordinalityOfUnit:NSDayCalendarUnit inUnit:NSWeekCalendarUnit forDate:self];
Expand Down
14 changes: 0 additions & 14 deletions Kal/NSMutableArrayAdditions.h

This file was deleted.

23 changes: 0 additions & 23 deletions Kal/NSMutableArrayAdditions.m

This file was deleted.

0 comments on commit eb0cdd8

Please sign in to comment.