Skip to content
This repository was archived by the owner on Mar 15, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
build/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.xcuserdatad
12 changes: 10 additions & 2 deletions Calendar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@
isa = PBXProject;
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Calendar" */;
compatibilityVersion = "Xcode 3.1";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
);
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -277,11 +281,13 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Calendar_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "Calendar-Info.plist";
PRODUCT_NAME = Calendar;
};
Expand All @@ -291,9 +297,11 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Calendar_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "Calendar-Info.plist";
PRODUCT_NAME = Calendar;
};
Expand All @@ -308,7 +316,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = iphoneos3.1.2;
SDKROOT = iphoneos;
};
name = Debug;
};
Expand All @@ -321,7 +329,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = iphoneos3.1.2;
SDKROOT = iphoneos;
};
name = Release;
};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 2 additions & 16 deletions Classes/CalendarAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ @implementation CalendarAppDelegate

- (void)applicationDidFinishLaunching:(UIApplication *)application {
// create calendar view
GCCalendarPortraitView *calendar = [[[GCCalendarPortraitView alloc] init] autorelease];
GCCalendarPortraitView *calendar = [[GCCalendarPortraitView alloc] init];
calendar.dataSource = self;
calendar.delegate = self;
calendar.hasAddButton = YES;

// create navigation view
UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:calendar] autorelease];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:calendar];

// create tab controller
tabController = [[UITabBarController alloc] init];
Expand All @@ -30,17 +30,6 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {
[window makeKeyAndVisible];
}


- (void)dealloc {
[window release];
window = nil;

[tabController release];
tabController = nil;

[super dealloc];
}

#pragma mark GCCalendarDataSource
- (NSArray *)calendarEventsForDate:(NSDate *)date {
NSMutableArray *events = [NSMutableArray array];
Expand Down Expand Up @@ -68,7 +57,6 @@ - (NSArray *)calendarEventsForDate:(NSDate *)date {
event.endDate = [[NSCalendar currentCalendar] dateFromComponents:components];

[events addObject:event];
[event release];
}


Expand All @@ -83,14 +71,12 @@ - (NSArray *)calendarEventsForDate:(NSDate *)date {
[components setHour:20];
evt.endDate = [[NSCalendar currentCalendar] dateFromComponents:components];
[events addObject:evt];
[evt release];

// create an all day event
GCCalendarEvent *event = [[GCCalendarEvent alloc] init];
event.allDayEvent = YES;
event.eventName = @"All Day Event";
[events addObject:event];
[event release];

return events;
}
Expand Down
2 changes: 1 addition & 1 deletion GCCalendar/GCCalendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ + (NSDateFormatter *)timeFormatter {
#pragma mark color list
+ (NSArray *)colors {
if (colors == nil) {
colors = [[NSArray arrayWithObjects:@"BLUE", @"GREEN", @"ORANGE", @"MAGENTA", @"PURPLE", @"RED", @"YELLOW", nil] retain];
colors = [NSArray arrayWithObjects:@"BLUE", @"GREEN", @"ORANGE", @"MAGENTA", @"PURPLE", @"RED", @"YELLOW", nil];
}

return colors;
Expand Down
2 changes: 1 addition & 1 deletion GCCalendar/GCCalendarDayView.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
id<GCCalendarDataSource> dataSource;
}

@property (nonatomic, retain) NSDate *date;
@property (nonatomic, strong) NSDate *date;
/*
accessor methods for accessing the contentOffset of the scroll view.
this is used to keep the scroll position the same from one day view
Expand Down
31 changes: 4 additions & 27 deletions GCCalendar/GCCalendarDayView.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ @implementation GCCalendarAllDayView
- (id)initWithEvents:(NSArray *)a {
if (self = [super init]) {
NSPredicate *pred = [NSPredicate predicateWithFormat:@"allDayEvent == YES"];
events = [[a filteredArrayUsingPredicate:pred] retain];
events = [a filteredArrayUsingPredicate:pred];

NSInteger eventCount = 0;
for (GCCalendarEvent *e in events) {
if (eventCount < 5) {
GCCalendarTile *tile = [[GCCalendarTile alloc] init];
tile.event = e;
[self addSubview:tile];
[tile release];

eventCount++;
}
Expand All @@ -53,12 +52,6 @@ - (id)initWithEvents:(NSArray *)a {

return self;
}
- (void)dealloc {
[events release];
events = nil;

[super dealloc];
}
- (BOOL)hasEvents {
return ([events count] != 0);
}
Expand Down Expand Up @@ -126,13 +119,12 @@ @implementation GCCalendarTodayView
- (id)initWithEvents:(NSArray *)a {
if (self = [super init]) {
NSPredicate *pred = [NSPredicate predicateWithFormat:@"allDayEvent == NO"];
events = [[a filteredArrayUsingPredicate:pred] retain];
events = [a filteredArrayUsingPredicate:pred];

for (GCCalendarEvent *e in events) {
GCCalendarTile *tile = [[GCCalendarTile alloc] init];
tile.event = e;
[self addSubview:tile];
[tile release];
}
}

Expand All @@ -141,12 +133,6 @@ - (id)initWithEvents:(NSArray *)a {
- (BOOL)hasEvents {
return ([events count] != 0);
}
- (void)dealloc {
[events release];
events = nil;

[super dealloc];
}
- (void)layoutSubviews {
for (UIView *view in self.subviews) {
// get calendar tile and associated event
Expand Down Expand Up @@ -287,11 +273,10 @@ @implementation GCCalendarDayView
#pragma mark create and destroy view
+ (void)initialize {
if(self == [GCCalendarDayView class]) {
timeStrings = [[NSArray arrayWithObjects:@"12",
timeStrings = [NSArray arrayWithObjects:@"12",
@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11",
[[NSBundle mainBundle] localizedStringForKey:@"NOON" value:@"" table:@"GCCalendar"],
@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11", @"12", nil]
retain];
@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11", @"12", nil];
}
}
- (id)initWithCalendarView:(GCCalendarView *)view {
Expand All @@ -301,20 +286,12 @@ - (id)initWithCalendarView:(GCCalendarView *)view {

return self;
}
- (void)dealloc {
self.date = nil;

[super dealloc];
}
- (void)reloadData {
// get new events for date
events = [dataSource calendarEventsForDate:date];

// drop all subviews
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
[allDayView release];
[todayView release];
[scrollView release];

// create all day view
allDayView = [[GCCalendarAllDayView alloc] initWithEvents:events];
Expand Down
2 changes: 1 addition & 1 deletion GCCalendar/GCCalendarEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
@property (nonatomic, copy) NSDate *startDate;
@property (nonatomic, copy) NSDate *endDate;
@property (nonatomic, copy) NSString *color;
@property (nonatomic, retain) id userInfo;
@property (nonatomic, strong) id userInfo;
@property (nonatomic) BOOL allDayEvent;

@end
9 changes: 0 additions & 9 deletions GCCalendar/GCCalendarEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,5 @@ - (id)init {
return self;
}

- (void)dealloc {
self.eventName = nil;
self.eventDescription = nil;
self.startDate = nil;
self.endDate = nil;
self.color = nil;

[super dealloc];
}

@end
23 changes: 6 additions & 17 deletions GCCalendar/GCCalendarPortraitView.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#define kAnimationDuration 0.3f

@interface GCCalendarPortraitView ()
@property (nonatomic, retain) NSDate *date;
@property (nonatomic, retain) GCCalendarDayView *dayView;
@property (nonatomic, strong) NSDate *date;
@property (nonatomic, strong) GCCalendarDayView *dayView;

- (void)reloadDayAnimated:(BOOL)animated context:(void *)context;
@end
Expand Down Expand Up @@ -50,13 +50,6 @@ - (id)init {
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];

self.date = nil;
self.dayView = nil;

[dayPicker release];

[super dealloc];
}

#pragma mark calendar actions
Expand All @@ -78,7 +71,7 @@ - (void)datePickerDidChangeDate:(GCDatePickerControl *)picker {

[[NSUserDefaults standardUserDefaults] setObject:date forKey:@"GCCalendarDate"];

[self reloadDayAnimated:YES context:[NSNumber numberWithInt:interval]];
[self reloadDayAnimated:YES context:(__bridge void *)([NSNumber numberWithInt:interval])];
}

#pragma mark button actions
Expand Down Expand Up @@ -106,7 +99,6 @@ - (void)setHasAddButton:(BOOL)b {
target:self
action:@selector(add)];
self.navigationItem.rightBarButtonItem = button;
[button release];
}
else {
self.navigationItem.rightBarButtonItem = nil;
Expand Down Expand Up @@ -145,7 +137,6 @@ - (void)loadView {
target:self
action:@selector(today)];
self.navigationItem.leftBarButtonItem = button;
[button release];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
Expand All @@ -166,7 +157,7 @@ - (void)viewDidDisappear:(BOOL)animated {
#pragma mark view animation functions
- (void)reloadDayAnimated:(BOOL)animated context:(void *)context {
if (animated) {
NSTimeInterval interval = [(NSNumber *)context doubleValue];
NSTimeInterval interval = [(__bridge NSNumber *)context doubleValue];

// block user interaction
dayPicker.userInteractionEnabled = NO;
Expand All @@ -181,7 +172,6 @@ - (void)reloadDayAnimated:(BOOL)animated context:(void *)context {
initialFrame.origin.x = 0 - initialFrame.size.width;
}
else {
[nextDayView release];
return;
}
nextDayView.frame = initialFrame;
Expand All @@ -191,7 +181,7 @@ - (void)reloadDayAnimated:(BOOL)animated context:(void *)context {

[self.view addSubview:nextDayView];

[UIView beginAnimations:nil context:nextDayView];
[UIView beginAnimations:nil context:(__bridge void*)nextDayView];
[UIView setAnimationDuration:kAnimationDuration];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
Expand All @@ -216,7 +206,7 @@ - (void)animationDidStop:(NSString *)animationID
finished:(NSNumber *)finished
context:(void *)context {

GCCalendarDayView *nextDayView = (GCCalendarDayView *)context;
GCCalendarDayView *nextDayView = (__bridge GCCalendarDayView *)context;

// cut variables
[dayView removeFromSuperview];
Expand All @@ -225,7 +215,6 @@ - (void)animationDidStop:(NSString *)animationID
self.dayView = nextDayView;

// release pointers
[nextDayView release];

// reset pickers
dayPicker.userInteractionEnabled = YES;
Expand Down
2 changes: 1 addition & 1 deletion GCCalendar/GCCalendarTile.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
GCCalendarEvent *event;
}

@property (nonatomic, retain) GCCalendarEvent *event;
@property (nonatomic, strong) GCCalendarEvent *event;

@end
7 changes: 0 additions & 7 deletions GCCalendar/GCCalendarTile.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,8 @@ - (id)init {

return self;
}
- (void)dealloc {
self.event = nil;

[super dealloc];
}
- (void)setEvent:(GCCalendarEvent *)e {
[event release];
event = e;
[event retain];

// set bg image
NSString *colorString = [event.color capitalizedString];
Expand Down
8 changes: 4 additions & 4 deletions GCCalendar/GCCalendarView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

@interface GCCalendarView : UIViewController {
// data source
id<GCCalendarDataSource> dataSource;
id<GCCalendarDataSource> __unsafe_unretained dataSource;

// delegate
id<GCCalendarDelegate> delegate;
id<GCCalendarDelegate> __unsafe_unretained delegate;
}

@property (nonatomic, assign) id<GCCalendarDataSource> dataSource;
@property (nonatomic, assign) id<GCCalendarDelegate> delegate;
@property (nonatomic, unsafe_unretained) id<GCCalendarDataSource> dataSource;
@property (nonatomic, unsafe_unretained) id<GCCalendarDelegate> delegate;

@end
Loading