From 2b538860c1daeb4e8789ff808d3ba26b79f98a9e Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Wed, 18 Jan 2012 13:49:19 +0800 Subject: [PATCH 1/2] Enable ARC. --- .../RootViewController/RootViewController.m | 4 +-- .../Delegate/TableViewPullAppDelegate.h | 4 +-- .../Delegate/TableViewPullAppDelegate.m | 5 ---- .../EGORefreshTableHeaderView.h | 4 +-- .../EGORefreshTableHeaderView.m | 5 ---- .../TableViewPull.xcodeproj/project.pbxproj | 4 +++ Demo/TableViewPull/main.m | 8 +++--- .../Classes/View/EGORefreshTableHeaderView.h | 6 ++-- .../Classes/View/EGORefreshTableHeaderView.m | 28 +++++++------------ 9 files changed, 25 insertions(+), 43 deletions(-) diff --git a/Demo/TableViewPull/Classes/Controller/RootViewController/RootViewController.m b/Demo/TableViewPull/Classes/Controller/RootViewController/RootViewController.m index 7153dc3..8d91cdf 100755 --- a/Demo/TableViewPull/Classes/Controller/RootViewController/RootViewController.m +++ b/Demo/TableViewPull/Classes/Controller/RootViewController/RootViewController.m @@ -37,7 +37,6 @@ - (void)viewDidLoad { view.delegate = self; [self.tableView addSubview:view]; _refreshHeaderView = view; - [view release]; } @@ -69,7 +68,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } // Configure the cell. @@ -157,7 +156,6 @@ - (void)viewDidUnload { - (void)dealloc { _refreshHeaderView = nil; - [super dealloc]; } diff --git a/Demo/TableViewPull/Classes/Delegate/TableViewPullAppDelegate.h b/Demo/TableViewPull/Classes/Delegate/TableViewPullAppDelegate.h index 94aebfc..d48eb54 100755 --- a/Demo/TableViewPull/Classes/Delegate/TableViewPullAppDelegate.h +++ b/Demo/TableViewPull/Classes/Delegate/TableViewPullAppDelegate.h @@ -30,8 +30,8 @@ UINavigationController *navigationController; } -@property (nonatomic, retain) IBOutlet UIWindow *window; -@property (nonatomic, retain) IBOutlet UINavigationController *navigationController; +@property (nonatomic, strong) IBOutlet UIWindow *window; +@property (nonatomic, strong) IBOutlet UINavigationController *navigationController; @end diff --git a/Demo/TableViewPull/Classes/Delegate/TableViewPullAppDelegate.m b/Demo/TableViewPull/Classes/Delegate/TableViewPullAppDelegate.m index c0acdd3..11749a3 100755 --- a/Demo/TableViewPull/Classes/Delegate/TableViewPullAppDelegate.m +++ b/Demo/TableViewPull/Classes/Delegate/TableViewPullAppDelegate.m @@ -54,11 +54,6 @@ - (void)applicationWillTerminate:(UIApplication *)application { #pragma mark - #pragma mark Memory management -- (void)dealloc { - [navigationController release]; - [window release]; - [super dealloc]; -} @end diff --git a/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.h b/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.h index 82077db..b20682b 100755 --- a/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.h +++ b/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.h @@ -36,7 +36,7 @@ typedef enum{ @protocol EGORefreshTableHeaderDelegate; @interface EGORefreshTableHeaderView : UIView { - id _delegate; + id __unsafe_unretained _delegate; EGOPullRefreshState _state; UILabel *_lastUpdatedLabel; @@ -47,7 +47,7 @@ typedef enum{ } -@property(nonatomic,assign) id delegate; +@property(nonatomic,unsafe_unretained) id delegate; - (void)refreshLastUpdatedDate; - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView; diff --git a/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.m b/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.m index 0def219..95bb029 100755 --- a/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.m +++ b/Demo/TableViewPull/Classes/View/RefreshTableHeaderView/EGORefreshTableHeaderView.m @@ -56,7 +56,6 @@ - (id)initWithFrame:(CGRect)frame { label.textAlignment = UITextAlignmentCenter; [self addSubview:label]; _lastUpdatedLabel=label; - [label release]; label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 48.0f, self.frame.size.width, 20.0f)]; label.autoresizingMask = UIViewAutoresizingFlexibleWidth; @@ -68,7 +67,6 @@ - (id)initWithFrame:(CGRect)frame { label.textAlignment = UITextAlignmentCenter; [self addSubview:label]; _statusLabel=label; - [label release]; CALayer *layer = [CALayer layer]; layer.frame = CGRectMake(25.0f, frame.size.height - 65.0f, 30.0f, 55.0f); @@ -88,7 +86,6 @@ - (id)initWithFrame:(CGRect)frame { view.frame = CGRectMake(25.0f, frame.size.height - 38.0f, 20.0f, 20.0f); [self addSubview:view]; _activityView = view; - [view release]; [self setState:EGOOPullRefreshNormal]; @@ -116,7 +113,6 @@ - (void)refreshLastUpdatedDate { _lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [formatter stringFromDate:date]]; [[NSUserDefaults standardUserDefaults] setObject:_lastUpdatedLabel.text forKey:@"EGORefreshTableView_LastRefresh"]; [[NSUserDefaults standardUserDefaults] synchronize]; - [formatter release]; } else { @@ -253,7 +249,6 @@ - (void)dealloc { _statusLabel = nil; _arrowImage = nil; _lastUpdatedLabel = nil; - [super dealloc]; } diff --git a/Demo/TableViewPull/TableViewPull.xcodeproj/project.pbxproj b/Demo/TableViewPull/TableViewPull.xcodeproj/project.pbxproj index f4b157e..a03092b 100755 --- a/Demo/TableViewPull/TableViewPull.xcodeproj/project.pbxproj +++ b/Demo/TableViewPull/TableViewPull.xcodeproj/project.pbxproj @@ -264,11 +264,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 = TableViewPull_Prefix.pch; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INFOPLIST_FILE = "Resources/TableViewPull-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 3.0; PRODUCT_NAME = TableViewPull; @@ -280,9 +282,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 = TableViewPull_Prefix.pch; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INFOPLIST_FILE = "Resources/TableViewPull-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 3.0; PRODUCT_NAME = TableViewPull; diff --git a/Demo/TableViewPull/main.m b/Demo/TableViewPull/main.m index 8916dd2..4c11bc8 100755 --- a/Demo/TableViewPull/main.m +++ b/Demo/TableViewPull/main.m @@ -10,8 +10,8 @@ int main(int argc, char *argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int retVal = UIApplicationMain(argc, argv, nil, nil); - [pool release]; - return retVal; + @autoreleasepool { + int retVal = UIApplicationMain(argc, argv, nil, nil); + return retVal; + } } diff --git a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h index 0ec72f0..b20682b 100755 --- a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h +++ b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h @@ -36,7 +36,7 @@ typedef enum{ @protocol EGORefreshTableHeaderDelegate; @interface EGORefreshTableHeaderView : UIView { - id _delegate; + id __unsafe_unretained _delegate; EGOPullRefreshState _state; UILabel *_lastUpdatedLabel; @@ -47,9 +47,7 @@ typedef enum{ } -@property(nonatomic,assign) id delegate; - -- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor; +@property(nonatomic,unsafe_unretained) id delegate; - (void)refreshLastUpdatedDate; - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView; diff --git a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m index 56b345b..95bb029 100755 --- a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m +++ b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m @@ -40,8 +40,8 @@ @implementation EGORefreshTableHeaderView @synthesize delegate=_delegate; -- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor { - if((self = [super initWithFrame:frame])) { +- (id)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { self.autoresizingMask = UIViewAutoresizingFlexibleWidth; self.backgroundColor = [UIColor colorWithRed:226.0/255.0 green:231.0/255.0 blue:237.0/255.0 alpha:1.0]; @@ -49,31 +49,29 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 30.0f, self.frame.size.width, 20.0f)]; label.autoresizingMask = UIViewAutoresizingFlexibleWidth; label.font = [UIFont systemFontOfSize:12.0f]; - label.textColor = textColor; + label.textColor = TEXT_COLOR; label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f]; label.shadowOffset = CGSizeMake(0.0f, 1.0f); label.backgroundColor = [UIColor clearColor]; label.textAlignment = UITextAlignmentCenter; [self addSubview:label]; _lastUpdatedLabel=label; - [label release]; label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 48.0f, self.frame.size.width, 20.0f)]; label.autoresizingMask = UIViewAutoresizingFlexibleWidth; label.font = [UIFont boldSystemFontOfSize:13.0f]; - label.textColor = textColor; + label.textColor = TEXT_COLOR; label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f]; label.shadowOffset = CGSizeMake(0.0f, 1.0f); label.backgroundColor = [UIColor clearColor]; label.textAlignment = UITextAlignmentCenter; [self addSubview:label]; _statusLabel=label; - [label release]; CALayer *layer = [CALayer layer]; layer.frame = CGRectMake(25.0f, frame.size.height - 65.0f, 30.0f, 55.0f); layer.contentsGravity = kCAGravityResizeAspect; - layer.contents = (id)[UIImage imageNamed:arrow].CGImage; + layer.contents = (id)[UIImage imageNamed:@"blueArrow.png"].CGImage; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000 if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { @@ -88,7 +86,6 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI view.frame = CGRectMake(25.0f, frame.size.height - 38.0f, 20.0f, 20.0f); [self addSubview:view]; _activityView = view; - [view release]; [self setState:EGOOPullRefreshNormal]; @@ -99,9 +96,6 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI } -- (id)initWithFrame:(CGRect)frame { - return [self initWithFrame:frame arrowImageName:@"blueArrow.png" textColor:TEXT_COLOR]; -} #pragma mark - #pragma mark Setters @@ -112,12 +106,11 @@ - (void)refreshLastUpdatedDate { NSDate *date = [_delegate egoRefreshTableHeaderDataSourceLastUpdated:self]; - [NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehaviorDefault]; - NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; - [dateFormatter setDateStyle:NSDateFormatterShortStyle]; - [dateFormatter setTimeStyle:NSDateFormatterShortStyle]; - - _lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [dateFormatter stringFromDate:date]]; + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + [formatter setAMSymbol:@"AM"]; + [formatter setPMSymbol:@"PM"]; + [formatter setDateFormat:@"MM/dd/yyyy hh:mm:a"]; + _lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [formatter stringFromDate:date]]; [[NSUserDefaults standardUserDefaults] setObject:_lastUpdatedLabel.text forKey:@"EGORefreshTableView_LastRefresh"]; [[NSUserDefaults standardUserDefaults] synchronize]; @@ -256,7 +249,6 @@ - (void)dealloc { _statusLabel = nil; _arrowImage = nil; _lastUpdatedLabel = nil; - [super dealloc]; } From dafe834634ac4e13ef5d4bb654a909d4dde21190 Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Wed, 18 Jan 2012 13:53:46 +0800 Subject: [PATCH 2/2] README updated & markdown. --- README | 0 README.md | 4 ++++ 2 files changed, 4 insertions(+) delete mode 100755 README create mode 100755 README.md diff --git a/README b/README deleted file mode 100755 index e69de29..0000000 diff --git a/README.md b/README.md new file mode 100755 index 0000000..2168a8e --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Dependencies +------------ + +Include "QuartzCore" in your target to successfully compile.