From 0314e4f3f0944cfbde24a9de8f7a5507486e63b1 Mon Sep 17 00:00:00 2001 From: Matt Galloway Date: Fri, 10 Feb 2012 22:17:51 +0000 Subject: [PATCH 1/5] Update to use the right SDKROOT --- Calendar.xcodeproj/project.pbxproj | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Calendar.xcodeproj/project.pbxproj b/Calendar.xcodeproj/project.pbxproj index 1122282..f9f3b1f 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 = ""; @@ -308,7 +312,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = iphoneos3.1.2; + SDKROOT = iphoneos; }; name = Debug; }; @@ -321,7 +325,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = iphoneos3.1.2; + SDKROOT = iphoneos; }; name = Release; }; From 42a2150bccd702d59861c65ebe3e97cecd552318 Mon Sep 17 00:00:00 2001 From: Matt Galloway Date: Fri, 10 Feb 2012 22:18:54 +0000 Subject: [PATCH 2/5] Add some more stuff to ignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) 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 From fb43fa43071522842161cadea08f492cc10dc504 Mon Sep 17 00:00:00 2001 From: Matt Galloway Date: Fri, 10 Feb 2012 22:19:06 +0000 Subject: [PATCH 3/5] Add the workspace stuff for Xcode 4 --- .../project.xcworkspace/contents.xcworkspacedata | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Calendar.xcodeproj/project.xcworkspace/contents.xcworkspacedata 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 @@ + + + + + From 6cfc1227f68fab4cf4563717973a2b069bfe3e8a Mon Sep 17 00:00:00 2001 From: Matt Galloway Date: Fri, 10 Feb 2012 22:23:43 +0000 Subject: [PATCH 4/5] Convert to use ARC --- Calendar.xcodeproj/project.pbxproj | 4 ++++ Classes/CalendarAppDelegate.m | 10 ++-------- GCCalendar/GCCalendar.m | 2 +- GCCalendar/GCCalendarDayView.h | 2 +- GCCalendar/GCCalendarDayView.m | 23 ++++------------------- GCCalendar/GCCalendarEvent.h | 2 +- GCCalendar/GCCalendarEvent.m | 9 --------- GCCalendar/GCCalendarPortraitView.m | 20 ++++++-------------- GCCalendar/GCCalendarTile.h | 2 +- GCCalendar/GCCalendarTile.m | 3 --- GCCalendar/GCCalendarView.h | 8 ++++---- GCCalendar/GCDatePickerControl.h | 2 +- GCCalendar/GCDatePickerControl.m | 9 --------- main.m | 8 ++++---- 14 files changed, 29 insertions(+), 75 deletions(-) diff --git a/Calendar.xcodeproj/project.pbxproj b/Calendar.xcodeproj/project.pbxproj index f9f3b1f..b47265a 100755 --- a/Calendar.xcodeproj/project.pbxproj +++ b/Calendar.xcodeproj/project.pbxproj @@ -281,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; }; @@ -295,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; }; diff --git a/Classes/CalendarAppDelegate.m b/Classes/CalendarAppDelegate.m index a3eda47..ad43839 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]; @@ -32,13 +32,10 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application { - (void)dealloc { - [window release]; window = nil; - [tabController release]; tabController = nil; - [super dealloc]; } #pragma mark GCCalendarDataSource @@ -68,7 +65,6 @@ - (NSArray *)calendarEventsForDate:(NSDate *)date { event.endDate = [[NSCalendar currentCalendar] dateFromComponents:components]; [events addObject:event]; - [event release]; } @@ -83,14 +79,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..737758b 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++; } @@ -54,10 +53,8 @@ - (id)initWithEvents:(NSArray *)a { return self; } - (void)dealloc { - [events release]; events = nil; - [super dealloc]; } - (BOOL)hasEvents { return ([events count] != 0); @@ -126,13 +123,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]; } } @@ -142,10 +138,8 @@ - (BOOL)hasEvents { return ([events count] != 0); } - (void)dealloc { - [events release]; events = nil; - [super dealloc]; } - (void)layoutSubviews { for (UIView *view in self.subviews) { @@ -287,11 +281,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 +294,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..cb3697c 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 @@ -51,12 +51,8 @@ - (id)init { - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - self.date = nil; - self.dayView = nil; - [dayPicker release]; - [super dealloc]; } #pragma mark calendar actions @@ -78,7 +74,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 +102,6 @@ - (void)setHasAddButton:(BOOL)b { target:self action:@selector(add)]; self.navigationItem.rightBarButtonItem = button; - [button release]; } else { self.navigationItem.rightBarButtonItem = nil; @@ -145,7 +140,6 @@ - (void)loadView { target:self action:@selector(today)]; self.navigationItem.leftBarButtonItem = button; - [button release]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; @@ -166,7 +160,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 +175,6 @@ - (void)reloadDayAnimated:(BOOL)animated context:(void *)context { initialFrame.origin.x = 0 - initialFrame.size.width; } else { - [nextDayView release]; return; } nextDayView.frame = initialFrame; @@ -191,7 +184,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 +209,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 +218,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..c676bb1 100644 --- a/GCCalendar/GCCalendarTile.m +++ b/GCCalendar/GCCalendarTile.m @@ -49,12 +49,9 @@ - (id)init { - (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..49cfa26 100644 --- a/GCCalendar/GCDatePickerControl.m +++ b/GCCalendar/GCDatePickerControl.m @@ -57,18 +57,13 @@ - (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 @@ -93,9 +88,7 @@ - (void)layoutSubviews { #pragma mark setters - (void)setDate:(NSDate *)newDate { - [date release]; date = newDate; - [date retain]; self.today = [GCCalendar dateIsToday:date]; @@ -145,11 +138,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; + } } From 4c89eb926b4190307671833bbcae0a2313b3b5fe Mon Sep 17 00:00:00 2001 From: Matt Galloway Date: Fri, 10 Feb 2012 22:31:54 +0000 Subject: [PATCH 5/5] Clean up deallocs --- Classes/CalendarAppDelegate.m | 8 -------- GCCalendar/GCCalendarDayView.m | 8 -------- GCCalendar/GCCalendarPortraitView.m | 3 --- GCCalendar/GCCalendarTile.m | 4 ---- GCCalendar/GCDatePickerControl.m | 9 --------- 5 files changed, 32 deletions(-) diff --git a/Classes/CalendarAppDelegate.m b/Classes/CalendarAppDelegate.m index ad43839..60234af 100644 --- a/Classes/CalendarAppDelegate.m +++ b/Classes/CalendarAppDelegate.m @@ -30,14 +30,6 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application { [window makeKeyAndVisible]; } - -- (void)dealloc { - window = nil; - - tabController = nil; - -} - #pragma mark GCCalendarDataSource - (NSArray *)calendarEventsForDate:(NSDate *)date { NSMutableArray *events = [NSMutableArray array]; diff --git a/GCCalendar/GCCalendarDayView.m b/GCCalendar/GCCalendarDayView.m index 737758b..d45f245 100644 --- a/GCCalendar/GCCalendarDayView.m +++ b/GCCalendar/GCCalendarDayView.m @@ -52,10 +52,6 @@ - (id)initWithEvents:(NSArray *)a { return self; } -- (void)dealloc { - events = nil; - -} - (BOOL)hasEvents { return ([events count] != 0); } @@ -137,10 +133,6 @@ - (id)initWithEvents:(NSArray *)a { - (BOOL)hasEvents { return ([events count] != 0); } -- (void)dealloc { - events = nil; - -} - (void)layoutSubviews { for (UIView *view in self.subviews) { // get calendar tile and associated event diff --git a/GCCalendar/GCCalendarPortraitView.m b/GCCalendar/GCCalendarPortraitView.m index cb3697c..728ba52 100644 --- a/GCCalendar/GCCalendarPortraitView.m +++ b/GCCalendar/GCCalendarPortraitView.m @@ -50,9 +50,6 @@ - (id)init { } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - - - } #pragma mark calendar actions diff --git a/GCCalendar/GCCalendarTile.m b/GCCalendar/GCCalendarTile.m index c676bb1..dd7e66a 100644 --- a/GCCalendar/GCCalendarTile.m +++ b/GCCalendar/GCCalendarTile.m @@ -46,10 +46,6 @@ - (id)init { return self; } -- (void)dealloc { - self.event = nil; - -} - (void)setEvent:(GCCalendarEvent *)e { event = e; diff --git a/GCCalendar/GCDatePickerControl.m b/GCCalendar/GCDatePickerControl.m index 49cfa26..6e14d49 100644 --- a/GCCalendar/GCDatePickerControl.m +++ b/GCCalendar/GCDatePickerControl.m @@ -56,15 +56,6 @@ - (id)init { return self; } -- (void)dealloc { - backButton = nil; - - forwardButton = nil; - - titleLabel = nil; - - -} #pragma mark view notifications - (CGSize)sizeThatFits:(CGSize)size {