Skip to content
Browse files

Apply ARC!

  • Loading branch information...
1 parent c98bf34 commit db451ab5d0d644009a8348c7b081ad30e3e022d2 @r-plus committed
View
4 AllAroundPullView.h
@@ -31,15 +31,11 @@ typedef enum {
AllAroundPullViewPosition _position;
}
-@property (nonatomic, retain) UIScrollView *scrollView;
-@property (nonatomic, assign) UIEdgeInsets originalInset;
@property (nonatomic, assign) NSTimeInterval timeout;
@property (nonatomic, assign) CGFloat threshold;
-@property (nonatomic, retain) CALayer *arrowImage;
@property (nonatomic, retain) UIActivityIndicatorView *activityView;
@property (nonatomic, readonly) BOOL isSideView;
@property (nonatomic, readonly) AllAroundPullViewPosition position;
-@property (nonatomic, copy) void (^allAroundPullViewActionHandler)(AllAroundPullView *view);
- (void)finishedLoading;
- (void)hideAllAroundPullViewIfNeed:(BOOL)disable;
View
22 AllAroundPullView.m
@@ -13,9 +13,13 @@
#define FLIP_ANIMATION_DURATION 0.18f
-@interface AllAroundPullView (Private)
+@interface AllAroundPullView ()
+@property (nonatomic, strong) UIScrollView *scrollView;
+@property (nonatomic, strong) CALayer *arrowImage;
@property (nonatomic, assign) AllAroundPullViewState state;
+@property (nonatomic, assign) UIEdgeInsets originalInset;
+@property (nonatomic, copy) void (^allAroundPullViewActionHandler)(AllAroundPullView *view);
- (void)startTimer;
- (void)dismissView;
@@ -28,8 +32,6 @@ - (id)initWithScrollView:(UIScrollView *)scroll position:(AllAroundPullViewPosit
@end
@implementation AllAroundPullView
-@synthesize scrollView, originalInset, arrowImage, activityView, timeout, threshold, allAroundPullViewActionHandler;
-@synthesize position = _position;
static const CGFloat kViewHeight = 60.0f;
static const CGFloat kSidePullViewWidth = 60.0f;
@@ -102,7 +104,7 @@ - (id)initWithScrollView:(UIScrollView *)scroll position:(AllAroundPullViewPosit
self.autoresizingMask = self.isSideView ? UIViewAutoresizingFlexibleHeight : UIViewAutoresizingFlexibleWidth;
self.backgroundColor = [UIColor clearColor];
self.threshold = 60.0f;
- self.arrowImage = [[[CALayer alloc] init] autorelease];
+ self.arrowImage = [[CALayer alloc] init];
UIImage *arrow = [UIImage imageNamed:@"arrow.png"];
self.arrowImage.contents = (id) arrow.CGImage;
CGRect arrowAndActivityFrame;
@@ -121,7 +123,7 @@ - (id)initWithScrollView:(UIScrollView *)scroll position:(AllAroundPullViewPosit
self.arrowImage.contentsScale = [[UIScreen mainScreen] scale];
[self.layer addSublayer:self.arrowImage];
- self.activityView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease];
+ self.activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
self.activityView.autoresizingMask = self.isSideView ? (UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin) : UIViewAutoresizingFlexibleWidth;
self.activityView.frame = arrowAndActivityFrame;
[self addSubview:self.activityView];
@@ -282,8 +284,8 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
[UIView animateWithDuration:0.2f animations:^{
[self setState:AllAroundPullViewStateLoading];
}];
- if (allAroundPullViewActionHandler)
- allAroundPullViewActionHandler(self);
+ if (self.allAroundPullViewActionHandler)
+ self.allAroundPullViewActionHandler(self);
}
}
}
@@ -315,12 +317,6 @@ - (void)startTimer {
- (void)dealloc {
[self.scrollView removeObserver:self forKeyPath:@"contentOffset"];
[self.scrollView removeObserver:self forKeyPath:@"contentSize"];
- [self.scrollView release];
- [self.arrowImage release];
- [self.activityView release];
- if (self.allAroundPullViewActionHandler)
- Block_release(self.allAroundPullViewActionHandler);
- [super dealloc];
}
@end
View
8 AllAroundPullViewDemo/AllAroundPullViewDemo.xcodeproj/project.pbxproj
@@ -16,6 +16,7 @@
0A7EE64915FB48640008E92F /* AAViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EE64815FB48640008E92F /* AAViewController.m */; };
0A7EE64C15FB48640008E92F /* AAViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0A7EE64A15FB48640008E92F /* AAViewController.xib */; };
0A7EE65315FB50ED0008E92F /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7EE65215FB50ED0008E92F /* QuartzCore.framework */; settings = {ATTRIBUTES = (Required, ); }; };
+ 0A9F062F1685ACB10046B3A0 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0A9F062E1685ACB10046B3A0 /* Default-568h@2x.png */; };
0AAB3B9F15FB52430083945A /* AllAroundPullView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AAB3B9E15FB52430083945A /* AllAroundPullView.m */; };
0AAB3BA215FB526B0083945A /* arrow.png in Resources */ = {isa = PBXBuildFile; fileRef = 0AAB3BA015FB526B0083945A /* arrow.png */; };
0AAB3BA315FB526B0083945A /* arrow@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0AAB3BA115FB526B0083945A /* arrow@2x.png */; };
@@ -36,6 +37,7 @@
0A7EE64815FB48640008E92F /* AAViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AAViewController.m; sourceTree = "<group>"; };
0A7EE64B15FB48640008E92F /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/AAViewController.xib; sourceTree = "<group>"; };
0A7EE65215FB50ED0008E92F /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+ 0A9F062E1685ACB10046B3A0 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
0AAB3B9D15FB52430083945A /* AllAroundPullView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AllAroundPullView.h; path = ../../AllAroundPullView.h; sourceTree = "<group>"; };
0AAB3B9E15FB52430083945A /* AllAroundPullView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AllAroundPullView.m; path = ../../AllAroundPullView.m; sourceTree = "<group>"; };
0AAB3BA015FB526B0083945A /* arrow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = arrow.png; path = ../../arrow.png; sourceTree = "<group>"; };
@@ -60,6 +62,7 @@
0A7EE62615FB48630008E92F = {
isa = PBXGroup;
children = (
+ 0A9F062E1685ACB10046B3A0 /* Default-568h@2x.png */,
0A7EE63B15FB48630008E92F /* AllAroundPullViewDemo */,
0A7EE63415FB48630008E92F /* Frameworks */,
0A7EE63215FB48630008E92F /* Products */,
@@ -167,6 +170,7 @@
0A7EE64C15FB48640008E92F /* AAViewController.xib in Resources */,
0AAB3BA215FB526B0083945A /* arrow.png in Resources */,
0AAB3BA315FB526B0083945A /* arrow@2x.png in Resources */,
+ 0A9F062F1685ACB10046B3A0 /* Default-568h@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -252,6 +256,8 @@
0A7EE65015FB48640008E92F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_OBJCPP_ARC_ABI = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "AllAroundPullViewDemo/AllAroundPullViewDemo-Prefix.pch";
INFOPLIST_FILE = "AllAroundPullViewDemo/AllAroundPullViewDemo-Info.plist";
@@ -263,6 +269,8 @@
0A7EE65115FB48640008E92F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_OBJCPP_ARC_ABI = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "AllAroundPullViewDemo/AllAroundPullViewDemo-Prefix.pch";
INFOPLIST_FILE = "AllAroundPullViewDemo/AllAroundPullViewDemo-Info.plist";
View
11 AllAroundPullViewDemo/AllAroundPullViewDemo/AAAppDelegate.m
@@ -15,18 +15,11 @@ @implementation AAAppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
-- (void)dealloc
-{
- [_window release];
- [_viewController release];
- [super dealloc];
-}
-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
- self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
- self.viewController = [[[AAViewController alloc] initWithNibName:@"AAViewController" bundle:nil] autorelease];
+ self.viewController = [[AAViewController alloc] initWithNibName:@"AAViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
View
8 AllAroundPullViewDemo/AllAroundPullViewDemo/AAViewController.m
@@ -35,7 +35,7 @@ - (void)viewDidLoad
[view performSelector:@selector(finishedLoading) withObject:nil afterDelay:1.0f];
}];
[self.scrollView addSubview:topPullView];
- [topPullView release];
+ //[topPullView release];
// bottom
AllAroundPullView *bottomPullView = [[AllAroundPullView alloc] initWithScrollView:self.scrollView position:AllAroundPullViewPositionBottom action:^(AllAroundPullView *view){
@@ -43,7 +43,7 @@ - (void)viewDidLoad
[view performSelector:@selector(finishedLoading) withObject:nil afterDelay:1.0f];
}];
[self.scrollView addSubview:bottomPullView];
- [bottomPullView release];
+ //[bottomPullView release];
// left
AllAroundPullView *leftPullView = [[AllAroundPullView alloc] initWithScrollView:self.scrollView position:AllAroundPullViewPositionLeft action:^(AllAroundPullView *view){
@@ -51,7 +51,7 @@ - (void)viewDidLoad
[view performSelector:@selector(finishedLoading) withObject:nil afterDelay:1.0f];
}];
[self.scrollView addSubview:leftPullView];
- [leftPullView release];
+ //[leftPullView release];
// right
AllAroundPullView *rightPullView = [[AllAroundPullView alloc] initWithScrollView:self.scrollView position:AllAroundPullViewPositionRight action:^(AllAroundPullView *view){
@@ -59,7 +59,7 @@ - (void)viewDidLoad
[view performSelector:@selector(finishedLoading) withObject:nil afterDelay:1.0f];
}];
[self.scrollView addSubview:rightPullView];
- [rightPullView release];
+ //[rightPullView release];
}
View
BIN AllAroundPullViewDemo/Default-568h@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
4 README.md
@@ -31,8 +31,8 @@ So, like this.
pull.threshold = 120.0f;
pull.activityView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
-## delegate design pattern
-maintained in `delegate` branch.
+## No-ARC and delegate design pattern
+maintained in `noARC` and `delegate` branch.
## License
See LICENSE file.

0 comments on commit db451ab

Please sign in to comment.
Something went wrong with that request. Please try again.