diff --git a/.gitignore b/.gitignore index debc8a9..d201bc7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ build/ *.pbxuser *.mode1v3 +*.mode2v3 +*.perspective +*.perspectivev3 +*.xcuserdatad diff --git a/Calendar.xcodeproj/project.pbxproj b/Calendar.xcodeproj/project.pbxproj index 1122282..b47265a 100755 --- a/Calendar.xcodeproj/project.pbxproj +++ b/Calendar.xcodeproj/project.pbxproj @@ -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 = ""; @@ -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; }; @@ -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; }; @@ -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; }; @@ -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; }; diff --git a/Calendar.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Calendar.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..87f5e28 --- /dev/null +++ b/Calendar.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Classes/CalendarAppDelegate.m b/Classes/CalendarAppDelegate.m index a3eda47..60234af 100644 --- a/Classes/CalendarAppDelegate.m +++ b/Classes/CalendarAppDelegate.m @@ -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]; @@ -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]; @@ -68,7 +57,6 @@ - (NSArray *)calendarEventsForDate:(NSDate *)date { event.endDate = [[NSCalendar currentCalendar] dateFromComponents:components]; [events addObject:event]; - [event release]; } @@ -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; } diff --git a/GCCalendar/GCCalendar.m b/GCCalendar/GCCalendar.m index 76a17ff..b692284 100644 --- a/GCCalendar/GCCalendar.m +++ b/GCCalendar/GCCalendar.m @@ -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; diff --git a/GCCalendar/GCCalendarDayView.h b/GCCalendar/GCCalendarDayView.h index 22155dd..d1bbe9c 100644 --- a/GCCalendar/GCCalendarDayView.h +++ b/GCCalendar/GCCalendarDayView.h @@ -33,7 +33,7 @@ id 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 diff --git a/GCCalendar/GCCalendarDayView.m b/GCCalendar/GCCalendarDayView.m index 7168abd..d45f245 100644 --- a/GCCalendar/GCCalendarDayView.m +++ b/GCCalendar/GCCalendarDayView.m @@ -36,7 +36,7 @@ @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) { @@ -44,7 +44,6 @@ - (id)initWithEvents:(NSArray *)a { GCCalendarTile *tile = [[GCCalendarTile alloc] init]; tile.event = e; [self addSubview:tile]; - [tile release]; eventCount++; } @@ -53,12 +52,6 @@ - (id)initWithEvents:(NSArray *)a { return self; } -- (void)dealloc { - [events release]; - events = nil; - - [super dealloc]; -} - (BOOL)hasEvents { return ([events count] != 0); } @@ -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]; } } @@ -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 @@ -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 { @@ -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]; diff --git a/GCCalendar/GCCalendarEvent.h b/GCCalendar/GCCalendarEvent.h index f970dc1..23bd288 100644 --- a/GCCalendar/GCCalendarEvent.h +++ b/GCCalendar/GCCalendarEvent.h @@ -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 diff --git a/GCCalendar/GCCalendarEvent.m b/GCCalendar/GCCalendarEvent.m index a40685b..1927f2c 100644 --- a/GCCalendar/GCCalendarEvent.m +++ b/GCCalendar/GCCalendarEvent.m @@ -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 diff --git a/GCCalendar/GCCalendarPortraitView.m b/GCCalendar/GCCalendarPortraitView.m index d3eaae1..728ba52 100644 --- a/GCCalendar/GCCalendarPortraitView.m +++ b/GCCalendar/GCCalendarPortraitView.m @@ -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 @@ -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 @@ -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 @@ -106,7 +99,6 @@ - (void)setHasAddButton:(BOOL)b { target:self action:@selector(add)]; self.navigationItem.rightBarButtonItem = button; - [button release]; } else { self.navigationItem.rightBarButtonItem = nil; @@ -145,7 +137,6 @@ - (void)loadView { target:self action:@selector(today)]; self.navigationItem.leftBarButtonItem = button; - [button release]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; @@ -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; @@ -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; @@ -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:)]; @@ -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]; @@ -225,7 +215,6 @@ - (void)animationDidStop:(NSString *)animationID self.dayView = nextDayView; // release pointers - [nextDayView release]; // reset pickers dayPicker.userInteractionEnabled = YES; diff --git a/GCCalendar/GCCalendarTile.h b/GCCalendar/GCCalendarTile.h index f498f8a..00b8d9f 100644 --- a/GCCalendar/GCCalendarTile.h +++ b/GCCalendar/GCCalendarTile.h @@ -30,6 +30,6 @@ GCCalendarEvent *event; } -@property (nonatomic, retain) GCCalendarEvent *event; +@property (nonatomic, strong) GCCalendarEvent *event; @end diff --git a/GCCalendar/GCCalendarTile.m b/GCCalendar/GCCalendarTile.m index 8371444..dd7e66a 100644 --- a/GCCalendar/GCCalendarTile.m +++ b/GCCalendar/GCCalendarTile.m @@ -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]; diff --git a/GCCalendar/GCCalendarView.h b/GCCalendar/GCCalendarView.h index d2840d3..1fbe01d 100644 --- a/GCCalendar/GCCalendarView.h +++ b/GCCalendar/GCCalendarView.h @@ -12,13 +12,13 @@ @interface GCCalendarView : UIViewController { // data source - id dataSource; + id __unsafe_unretained dataSource; // delegate - id delegate; + id __unsafe_unretained delegate; } -@property (nonatomic, assign) id dataSource; -@property (nonatomic, assign) id delegate; +@property (nonatomic, unsafe_unretained) id dataSource; +@property (nonatomic, unsafe_unretained) id delegate; @end diff --git a/GCCalendar/GCDatePickerControl.h b/GCCalendar/GCDatePickerControl.h index 56e5957..13be0d8 100644 --- a/GCCalendar/GCDatePickerControl.h +++ b/GCCalendar/GCDatePickerControl.h @@ -30,6 +30,6 @@ BOOL today; } -@property (nonatomic, retain) NSDate *date; +@property (nonatomic, strong) NSDate *date; @end diff --git a/GCCalendar/GCDatePickerControl.m b/GCCalendar/GCDatePickerControl.m index 49ce02f..6e14d49 100644 --- a/GCCalendar/GCDatePickerControl.m +++ b/GCCalendar/GCDatePickerControl.m @@ -56,20 +56,6 @@ - (id)init { return self; } -- (void)dealloc { - [backButton release]; - backButton = nil; - - [forwardButton release]; - forwardButton = nil; - - [titleLabel release]; - titleLabel = nil; - - self.date = nil; - - [super dealloc]; -} #pragma mark view notifications - (CGSize)sizeThatFits:(CGSize)size { @@ -93,9 +79,7 @@ - (void)layoutSubviews { #pragma mark setters - (void)setDate:(NSDate *)newDate { - [date release]; date = newDate; - [date retain]; self.today = [GCCalendar dateIsToday:date]; @@ -145,11 +129,9 @@ - (void)buttonPressed:(UIButton *)sender { if(sender == backButton) { NSDate *newDate = [[NSDate alloc] initWithTimeInterval:-kSecondsInDay sinceDate:date]; self.date = newDate; - [newDate release]; } else if(sender == forwardButton) { NSDate *newDate = [[NSDate alloc] initWithTimeInterval:kSecondsInDay sinceDate:date]; self.date = newDate; - [newDate release]; } [self sendActionsForControlEvents:UIControlEventValueChanged]; diff --git a/main.m b/main.m index 0415e1f..7491e2e 100644 --- a/main.m +++ b/main.m @@ -10,8 +10,8 @@ int main(int argc, char *argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int retVal = UIApplicationMain(argc, argv, nil, @"CalendarAppDelegate"); - [pool release]; - return retVal; + @autoreleasepool { + int retVal = UIApplicationMain(argc, argv, nil, @"CalendarAppDelegate"); + return retVal; + } }