From a66f681e05d24e31969dae384fea5e8757dc2f6f Mon Sep 17 00:00:00 2001 From: Bob McCune Date: Tue, 28 Feb 2012 21:17:10 -0600 Subject: [PATCH] Converting to ARC. --- .../AVPlayerLayerViewController.h | 8 ++- .../AVPlayerLayerViewController.m | 8 ++- Classes/CoreAnimation/BatmanViewController.h | 6 +-- Classes/CoreAnimation/BatmanViewController.m | 30 +++++++----- Classes/CoreAnimation/CALayer+Additions.h | 4 +- Classes/CoreAnimation/CALayer+Additions.m | 3 +- Classes/CoreAnimation/CharlieViewController.h | 6 +-- Classes/CoreAnimation/CharlieViewController.m | 3 +- .../ImplicitAnimationsViewController.h | 9 ++-- .../ImplicitAnimationsViewController.m | 49 ++++++++++--------- .../CoreAnimation/MakeItStickViewController.h | 6 +-- .../CoreAnimation/MakeItStickViewController.m | 27 +++++----- Classes/CoreAnimation/PacmanViewController.h | 2 +- Classes/CoreAnimation/PacmanViewController.m | 16 ++---- Classes/CoreAnimation/PulseViewController.h | 2 +- Classes/CoreAnimation/PulseViewController.m | 2 +- .../CoreAnimation/ReflectionViewController.h | 2 +- .../CoreAnimation/ReflectionViewController.m | 2 +- .../SublayerTransformViewController.h | 2 +- .../SublayerTransformViewController.m | 2 +- .../CoreAnimation/TachometerViewController.h | 4 +- .../CoreAnimation/TachometerViewController.m | 8 +-- Classes/CoreAnimationAppDelegate.h | 12 ++--- Classes/CoreAnimationAppDelegate.m | 13 ++--- Classes/RootViewController.h | 7 +-- Classes/RootViewController.m | 30 +++++------- Classes/UIKitAnimation/FlipViewController.h | 2 +- Classes/UIKitAnimation/FlipViewController.m | 7 +-- Classes/UIKitAnimation/NoteView.h | 9 ++-- Classes/UIKitAnimation/NoteView.m | 29 +++++------ .../SimpleViewPropertyAnimation.h | 2 +- .../SimpleViewPropertyAnimation.m | 9 +--- .../StickyNotesViewController.h | 4 +- .../StickyNotesViewController.m | 11 ++--- CoreAnimation.xcodeproj/project.pbxproj | 2 + main.m | 8 +-- 36 files changed, 152 insertions(+), 194 deletions(-) diff --git a/Classes/CoreAnimation/AVPlayerLayerViewController.h b/Classes/CoreAnimation/AVPlayerLayerViewController.h index 4f894ac..6e30b35 100644 --- a/Classes/CoreAnimation/AVPlayerLayerViewController.h +++ b/Classes/CoreAnimation/AVPlayerLayerViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -27,10 +27,8 @@ /* * Demo of moving AVPlayerLayer around in 3D space. */ -@interface AVPlayerLayerViewController : UIViewController { - AVPlayer *player; -} +@interface AVPlayerLayerViewController : UIViewController -@property (nonatomic, retain) AVPlayer *player; +@property (nonatomic, strong) AVPlayer *player; @end diff --git a/Classes/CoreAnimation/AVPlayerLayerViewController.m b/Classes/CoreAnimation/AVPlayerLayerViewController.m index 19222f2..9ac6d81 100644 --- a/Classes/CoreAnimation/AVPlayerLayerViewController.m +++ b/Classes/CoreAnimation/AVPlayerLayerViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -27,6 +27,8 @@ @implementation AVPlayerLayerViewController +@synthesize player = _player; + + (NSString *)displayName { return @"Amazon Babe"; } @@ -91,10 +93,6 @@ - (void)spinIt { - (void)dealloc { [self.player pause]; - self.player = nil; - [super dealloc]; } -@synthesize player; - @end diff --git a/Classes/CoreAnimation/BatmanViewController.h b/Classes/CoreAnimation/BatmanViewController.h index c0c8f64..3dc91b6 100644 --- a/Classes/CoreAnimation/BatmanViewController.h +++ b/Classes/CoreAnimation/BatmanViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -25,9 +25,7 @@ /* * Demo showing how to animate transforms and combine multiple animations into a CAAnimationGroup. */ -@interface BatmanViewController : UIViewController { - CALayer *logoLayer; -} +@interface BatmanViewController : UIViewController - (IBAction)rotate:(id)sender; - (IBAction)scaleUp; diff --git a/Classes/CoreAnimation/BatmanViewController.m b/Classes/CoreAnimation/BatmanViewController.m index 391e5a9..42fba86 100644 --- a/Classes/CoreAnimation/BatmanViewController.m +++ b/Classes/CoreAnimation/BatmanViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -27,8 +27,14 @@ #define ROTATE_LEFT_TAG 3 #define ROTATE_RIGHT_TAG 4 +@interface BatmanViewController () +@property (nonatomic, strong) CALayer *logoLayer; +@end + @implementation BatmanViewController +@synthesize logoLayer = _logoLayer; + - (id)init { self = [super initWithNibName:@"BatmanView" bundle:nil]; return self; @@ -46,13 +52,13 @@ - (void)viewDidLoad { UIImage *image = [UIImage imageNamed:@"batman.png"]; - logoLayer = [CALayer layer]; - logoLayer.bounds = CGRectMake(0, 0, image.size.width, image.size.height); - logoLayer.position = CGPointMake(160, 180); - logoLayer.contents = (id)image.CGImage; + self.logoLayer = [CALayer layer]; + self.logoLayer.bounds = CGRectMake(0, 0, image.size.width, image.size.height); + self.logoLayer.position = CGPointMake(160, 180); + self.logoLayer.contents = (id)image.CGImage; // Add layer as a sublayer of the UIView's layer - [self.view.layer addSublayer:logoLayer]; + [self.view.layer addSublayer:self.logoLayer]; } - (IBAction)rotate:(id)sender { @@ -61,7 +67,7 @@ - (IBAction)rotate:(id)sender { rotationAnimation.toValue = [NSNumber numberWithFloat:(2 * M_PI) * direction]; rotationAnimation.duration = 1.0f; rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; - [logoLayer addAnimation:rotationAnimation forKey:@"rotateAnimation"]; + [self.logoLayer addAnimation:rotationAnimation forKey:@"rotateAnimation"]; } - (void)scaleByFactor:(CGFloat)factor { @@ -71,17 +77,17 @@ - (void)scaleByFactor:(CGFloat)factor { scaleAnimation.duration = 3.0f; scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; // Set the model layer's property so the animation sticks at the 'toValue' state - [logoLayer setValue:scaleFactor forKeyPath:@"transform.scale"]; - [logoLayer addAnimation:scaleAnimation forKey:@"transformAnimation"]; + [self.logoLayer setValue:scaleFactor forKeyPath:@"transform.scale"]; + [self.logoLayer addAnimation:scaleAnimation forKey:@"transformAnimation"]; } - (IBAction)scaleDown { - CGFloat factor = [[logoLayer valueForKeyPath:@"transform.scale"] floatValue] > 1.0 ? 1.0 : 0.5; + CGFloat factor = [[self.logoLayer valueForKeyPath:@"transform.scale"] floatValue] > 1.0 ? 1.0 : 0.5; [self scaleByFactor:factor]; } - (IBAction)scaleUp { - CGFloat factor = [[logoLayer valueForKeyPath:@"transform.scale"] floatValue] == 0.5 ? 1.0 : 1.5; + CGFloat factor = [[self.logoLayer valueForKeyPath:@"transform.scale"] floatValue] == 0.5 ? 1.0 : 1.5; [self scaleByFactor:factor]; } @@ -106,7 +112,7 @@ - (IBAction)doBatmanAnimation { animationGroup.repeatCount = HUGE_VALF; [animationGroup setAnimations:[NSArray arrayWithObjects:rotationAnimation, scaleAnimation, nil]]; - [logoLayer addAnimation:animationGroup forKey:@"animationGroup"]; + [self.logoLayer addAnimation:animationGroup forKey:@"animationGroup"]; } @end diff --git a/Classes/CoreAnimation/CALayer+Additions.h b/Classes/CoreAnimation/CALayer+Additions.h index d175bf3..159d740 100644 --- a/Classes/CoreAnimation/CALayer+Additions.h +++ b/Classes/CoreAnimation/CALayer+Additions.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -21,8 +21,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // -#import - @interface CALayer (Additions) diff --git a/Classes/CoreAnimation/CALayer+Additions.m b/Classes/CoreAnimation/CALayer+Additions.m index 4e2cd11..26520e1 100644 --- a/Classes/CoreAnimation/CALayer+Additions.m +++ b/Classes/CoreAnimation/CALayer+Additions.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -24,7 +24,6 @@ #import "CALayer+Additions.h" - @implementation CALayer (Additions) - (void)adjustWidthBy:(CGFloat)value { diff --git a/Classes/CoreAnimation/CharlieViewController.h b/Classes/CoreAnimation/CharlieViewController.h index aee8e03..7e87578 100644 --- a/Classes/CoreAnimation/CharlieViewController.h +++ b/Classes/CoreAnimation/CharlieViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -25,8 +25,6 @@ /* * Demo using shadowPath property to give greater depth and realism to layers. Tap photo to toggle shadow path. */ -@interface CharlieViewController : UIViewController { - -} +@interface CharlieViewController : UIViewController @end diff --git a/Classes/CoreAnimation/CharlieViewController.m b/Classes/CoreAnimation/CharlieViewController.m index fb0db14..520a1cb 100644 --- a/Classes/CoreAnimation/CharlieViewController.m +++ b/Classes/CoreAnimation/CharlieViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -76,7 +76,6 @@ - (void)viewDidLoad { UIGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(togglePath)]; [self.view addGestureRecognizer:tapRecognizer]; - [tapRecognizer release]; } - (void)togglePath { diff --git a/Classes/CoreAnimation/ImplicitAnimationsViewController.h b/Classes/CoreAnimation/ImplicitAnimationsViewController.h index ec7e928..c0bf426 100644 --- a/Classes/CoreAnimation/ImplicitAnimationsViewController.h +++ b/Classes/CoreAnimation/ImplicitAnimationsViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -25,12 +25,9 @@ /* * Simple demo showing implicit property animations. */ -@interface ImplicitAnimationsViewController : UIViewController { - CALayer *layer; - UISwitch *actionsSwitch; -} +@interface ImplicitAnimationsViewController : UIViewController -@property (nonatomic, retain) IBOutlet UISwitch *actionsSwitch; +@property (nonatomic, strong) IBOutlet UISwitch *actionsSwitch; - (IBAction)toggleCornerRadius; - (IBAction)toggleBorder; diff --git a/Classes/CoreAnimation/ImplicitAnimationsViewController.m b/Classes/CoreAnimation/ImplicitAnimationsViewController.m index a3c24a0..adb4fdd 100644 --- a/Classes/CoreAnimation/ImplicitAnimationsViewController.m +++ b/Classes/CoreAnimation/ImplicitAnimationsViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -29,21 +29,28 @@ #define ORGINAL_POSITION CGPointMake(160, 250) #define MOVED_POSITON CGPointMake(200, 290) +@interface ImplicitAnimationsViewController () +@property (nonatomic, strong) CALayer *layer; +@end + @implementation ImplicitAnimationsViewController +@synthesize actionsSwitch = _actionsSwitch; +@synthesize layer = _layer; + + (NSString *)displayName { return @"Animatable Properties"; } - (id)init { if ((self = [super initWithNibName:@"LayerView" bundle:nil])) { - layer = [CALayer layer]; - layer.bounds = CGRectMake(0, 0, 200, 200); - layer.position = CGPointMake(160, 250); - layer.backgroundColor = [UIColor redColor].CGColor; - layer.borderColor = [UIColor blackColor].CGColor; - layer.opacity = 1.0f; - [self.view.layer addSublayer:layer]; + self.layer = [CALayer layer]; + self.layer.bounds = CGRectMake(0, 0, 200, 200); + self.layer.position = CGPointMake(160, 250); + self.layer.backgroundColor = [UIColor redColor].CGColor; + self.layer.borderColor = [UIColor blackColor].CGColor; + self.layer.opacity = 1.0f; + [self.view.layer addSublayer:self.layer]; } return self; } @@ -55,36 +62,34 @@ - (void)viewDidLoad { } - (IBAction)toggleColor { - [CATransaction setDisableActions:actionsSwitch.on]; + [CATransaction setDisableActions:self.actionsSwitch.on]; CGColorRef redColor = [UIColor redColor].CGColor, blueColor = [UIColor blueColor].CGColor; - layer.backgroundColor = (layer.backgroundColor == redColor) ? blueColor : redColor; + self.layer.backgroundColor = (self.layer.backgroundColor == redColor) ? blueColor : redColor; } - (IBAction)toggleCornerRadius { - [CATransaction setDisableActions:actionsSwitch.on]; - layer.cornerRadius = (layer.cornerRadius == 0.0f) ? 30.0f : 0.0f; + [CATransaction setDisableActions:self.actionsSwitch.on]; + self.layer.cornerRadius = (self.layer.cornerRadius == 0.0f) ? 30.0f : 0.0f; } - (IBAction)toggleBorder { - [CATransaction setDisableActions:actionsSwitch.on]; - layer.borderWidth = (layer.borderWidth == 0.0f) ? 10.0f : 0.0f; + [CATransaction setDisableActions:self.actionsSwitch.on]; + self.layer.borderWidth = (self.layer.borderWidth == 0.0f) ? 10.0f : 0.0f; } - (IBAction)toggleOpacity { - [CATransaction setDisableActions:actionsSwitch.on]; - layer.opacity = (layer.opacity == 1.0f) ? 0.5f : 1.0f; + [CATransaction setDisableActions:self.actionsSwitch.on]; + self.layer.opacity = (self.layer.opacity == 1.0f) ? 0.5f : 1.0f; } - (IBAction)toggleBounds { - [CATransaction setDisableActions:actionsSwitch.on]; - [layer adjustWidthBy:layer.bounds.size.width == layer.bounds.size.height ? 100 : -100]; + [CATransaction setDisableActions:self.actionsSwitch.on]; + [self.layer adjustWidthBy:self.layer.bounds.size.width == self.layer.bounds.size.height ? 100 : -100]; } - (IBAction)togglePosition { - [CATransaction setDisableActions:actionsSwitch.on]; - layer.position = layer.position.x == 160 ? MOVED_POSITON : ORGINAL_POSITION; + [CATransaction setDisableActions:self.actionsSwitch.on]; + self.layer.position = self.layer.position.x == 160 ? MOVED_POSITON : ORGINAL_POSITION; } -@synthesize actionsSwitch; - @end diff --git a/Classes/CoreAnimation/MakeItStickViewController.h b/Classes/CoreAnimation/MakeItStickViewController.h index 7860589..a2a7abc 100644 --- a/Classes/CoreAnimation/MakeItStickViewController.h +++ b/Classes/CoreAnimation/MakeItStickViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -26,8 +26,6 @@ * Demo pointing out a gotcha when applying animations. Need to update the model value to ensure * the animation's 'toValue' sticks. */ -@interface MakeItStickViewController : UIViewController { - CALayer *layer; -} +@interface MakeItStickViewController : UIViewController @end diff --git a/Classes/CoreAnimation/MakeItStickViewController.m b/Classes/CoreAnimation/MakeItStickViewController.m index e79acb8..8d2c829 100644 --- a/Classes/CoreAnimation/MakeItStickViewController.m +++ b/Classes/CoreAnimation/MakeItStickViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -24,8 +24,14 @@ #import "MakeItStickViewController.h" +@interface MakeItStickViewController () +@property (nonatomic, strong) CALayer *layer; +@end + @implementation MakeItStickViewController +@synthesize layer = _layer; + + (NSString *)displayName { return @"Make it Stick"; } @@ -33,25 +39,24 @@ + (NSString *)displayName { - (void)viewDidLoad { [super viewDidLoad]; self.title = [[self class] displayName]; - UIImage *image = [UIImage imageNamed:@"heart.png"]; - layer = [CALayer layer]; - layer.contents = (id)image.CGImage; - layer.bounds = CGRectMake(0, 0, image.size.width, image.size.height); - layer.position = CGPointMake(160, 200); - [self.view.layer addSublayer:layer]; + UIImage *image = [UIImage imageNamed:@"heart"]; + self.layer = [CALayer layer]; + self.layer.contents = (id)image.CGImage; + self.layer.bounds = CGRectMake(0, 0, image.size.width, image.size.height); + self.layer.position = CGPointMake(160, 200); + [self.view.layer addSublayer:self.layer]; UIGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fadeIt)]; [self.view addGestureRecognizer:recognizer]; - [recognizer release]; } - (void)fadeIt { CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"]; animation.toValue = [NSNumber numberWithFloat:0.0]; - animation.fromValue = [NSNumber numberWithFloat:layer.opacity]; + animation.fromValue = [NSNumber numberWithFloat:self.layer.opacity]; animation.duration = 1.0; - layer.opacity = 0.0; // This is required to update the model's value. Comment out to see what happens. - [layer addAnimation:animation forKey:@"animateOpacity"]; + self.layer.opacity = 0.0; // This is required to update the model's value. Comment out to see what happens. + [self.layer addAnimation:animation forKey:@"animateOpacity"]; } @end diff --git a/Classes/CoreAnimation/PacmanViewController.h b/Classes/CoreAnimation/PacmanViewController.h index ca291e0..614888a 100644 --- a/Classes/CoreAnimation/PacmanViewController.h +++ b/Classes/CoreAnimation/PacmanViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/Classes/CoreAnimation/PacmanViewController.m b/Classes/CoreAnimation/PacmanViewController.m index 0bd6eb7..dc0add8 100644 --- a/Classes/CoreAnimation/PacmanViewController.m +++ b/Classes/CoreAnimation/PacmanViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -42,20 +42,20 @@ - (void)viewDidLoad { CGPoint arcCenter = CGPointMake(radius, radius); // Create a UIBezierPath for Pacman's open state - pacmanOpenPath = [[UIBezierPath bezierPathWithArcCenter:arcCenter + pacmanOpenPath = [UIBezierPath bezierPathWithArcCenter:arcCenter radius:radius startAngle:DEGREES_TO_RADIANS(35) endAngle:DEGREES_TO_RADIANS(315) - clockwise:YES] retain]; + clockwise:YES]; [pacmanOpenPath addLineToPoint:arcCenter]; [pacmanOpenPath closePath]; // Create a UIBezierPath for Pacman's close state - pacmanClosedPath = [[UIBezierPath bezierPathWithArcCenter:arcCenter + pacmanClosedPath = [UIBezierPath bezierPathWithArcCenter:arcCenter radius:radius startAngle:DEGREES_TO_RADIANS(1) endAngle:DEGREES_TO_RADIANS(359) - clockwise:YES] retain]; + clockwise:YES]; [pacmanClosedPath addLineToPoint:arcCenter]; [pacmanClosedPath closePath]; @@ -72,7 +72,6 @@ - (void)viewDidLoad { SEL startSelector = @selector(startAnimation); UIGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:startSelector]; [self.view addGestureRecognizer:recognizer]; - [recognizer release]; // start animation after short delay [self performSelector:startSelector withObject:nil afterDelay:1.0]; @@ -109,10 +108,5 @@ - (void)startAnimation { [shapeLayer addAnimation:moveAnimation forKey:@"moveAnimation"]; } -- (void)dealloc { - CARelease(pacmanOpenPath); - CARelease(pacmanClosedPath); - [super dealloc]; -} @end diff --git a/Classes/CoreAnimation/PulseViewController.h b/Classes/CoreAnimation/PulseViewController.h index d8ffae4..e7451dc 100644 --- a/Classes/CoreAnimation/PulseViewController.h +++ b/Classes/CoreAnimation/PulseViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/Classes/CoreAnimation/PulseViewController.m b/Classes/CoreAnimation/PulseViewController.m index 6f25e22..69fafae 100644 --- a/Classes/CoreAnimation/PulseViewController.m +++ b/Classes/CoreAnimation/PulseViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/Classes/CoreAnimation/ReflectionViewController.h b/Classes/CoreAnimation/ReflectionViewController.h index ce700c5..f476bf2 100644 --- a/Classes/CoreAnimation/ReflectionViewController.h +++ b/Classes/CoreAnimation/ReflectionViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/Classes/CoreAnimation/ReflectionViewController.m b/Classes/CoreAnimation/ReflectionViewController.m index cf6f7a1..e714349 100644 --- a/Classes/CoreAnimation/ReflectionViewController.m +++ b/Classes/CoreAnimation/ReflectionViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/Classes/CoreAnimation/SublayerTransformViewController.h b/Classes/CoreAnimation/SublayerTransformViewController.h index c3bdcd7..a475899 100644 --- a/Classes/CoreAnimation/SublayerTransformViewController.h +++ b/Classes/CoreAnimation/SublayerTransformViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/Classes/CoreAnimation/SublayerTransformViewController.m b/Classes/CoreAnimation/SublayerTransformViewController.m index aaea10b..09be13b 100644 --- a/Classes/CoreAnimation/SublayerTransformViewController.m +++ b/Classes/CoreAnimation/SublayerTransformViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/Classes/CoreAnimation/TachometerViewController.h b/Classes/CoreAnimation/TachometerViewController.h index 1868c87..d42f8d8 100644 --- a/Classes/CoreAnimation/TachometerViewController.h +++ b/Classes/CoreAnimation/TachometerViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -33,6 +33,6 @@ CALayer *pinLayer; } -@property (nonatomic, retain) AVAudioPlayer *audioPlayer; +@property (nonatomic, strong) AVAudioPlayer *audioPlayer; @end diff --git a/Classes/CoreAnimation/TachometerViewController.m b/Classes/CoreAnimation/TachometerViewController.m index ae36f70..138b2be 100644 --- a/Classes/CoreAnimation/TachometerViewController.m +++ b/Classes/CoreAnimation/TachometerViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -37,7 +37,7 @@ - (void)viewDidLoad { // The animation was fun without the audio, but it's WAY better with the engine rev sound. NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"engine" ofType:@"caf"]]; - self.audioPlayer = [[[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil] autorelease]; + self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil]; [self.audioPlayer prepareToPlay]; UIImage *image = [UIImage imageNamed:@"metalbackground.png"]; @@ -77,10 +77,6 @@ - (void)go:(id)sender { [pinLayer addAnimation:rotationAnimation forKey:@"revItUpAnimation"]; } -- (void)dealloc { - self.audioPlayer = nil; - [super dealloc]; -} @synthesize audioPlayer; diff --git a/Classes/CoreAnimationAppDelegate.h b/Classes/CoreAnimationAppDelegate.h index bf9aa05..0d49e0c 100644 --- a/Classes/CoreAnimationAppDelegate.h +++ b/Classes/CoreAnimationAppDelegate.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -22,14 +22,10 @@ // THE SOFTWARE. // -@interface CoreAnimationAppDelegate : NSObject { - - UIWindow *window; - UINavigationController *navigationController; -} +@interface CoreAnimationAppDelegate : NSObject -@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/Classes/CoreAnimationAppDelegate.m b/Classes/CoreAnimationAppDelegate.m index f269358..a2920d4 100644 --- a/Classes/CoreAnimationAppDelegate.m +++ b/Classes/CoreAnimationAppDelegate.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -27,8 +27,8 @@ @implementation CoreAnimationAppDelegate -@synthesize window; -@synthesize navigationController; +@synthesize window = _window; +@synthesize navigationController = _navigationController; #pragma mark - #pragma mark Application lifecycle @@ -38,17 +38,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // Override point for customization after application launch. // Add the navigation controller's view to the window and display. - [self.window addSubview:navigationController.view]; + [self.window addSubview:self.navigationController.view]; [self.window makeKeyAndVisible]; return YES; } -- (void)dealloc { - [navigationController release]; - [window release]; - [super dealloc]; -} @end diff --git a/Classes/RootViewController.h b/Classes/RootViewController.h index 2c0a690..1804648 100644 --- a/Classes/RootViewController.h +++ b/Classes/RootViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -22,9 +22,6 @@ // THE SOFTWARE. // -@interface RootViewController : UITableViewController { -@private - NSMutableArray *items; -} +@interface RootViewController : UITableViewController @end diff --git a/Classes/RootViewController.m b/Classes/RootViewController.m index 5c1e4d2..ef3e607 100644 --- a/Classes/RootViewController.m +++ b/Classes/RootViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -38,20 +38,22 @@ #import "MakeItStickViewController.h" #import "SublayerTransformViewController.h" -@interface UIViewController (Private) +@interface UIViewController () +@property (nonatomic, strong) NSMutableArray *items; + (NSString *)displayName; @end @implementation RootViewController +@synthesize items = _items; + #pragma mark - #pragma mark View lifecycle - - (void)viewDidLoad { [super viewDidLoad]; - items = [[NSMutableArray alloc] init]; + self.items = [[NSMutableArray alloc] init]; NSMutableArray *layersList = [NSMutableArray array]; [layersList addObject:[ImplicitAnimationsViewController class]]; @@ -66,7 +68,7 @@ - (void)viewDidLoad { [layersList addObject:[PulseViewController class]]; NSDictionary *layers = [NSDictionary dictionaryWithObject:layersList forKey:@"Core Animation"]; - [items addObject:layers]; + [self.items addObject:layers]; NSMutableArray *uiKitList = [NSMutableArray array]; [uiKitList addObject:[SimpleViewPropertyAnimation class]]; @@ -75,7 +77,7 @@ - (void)viewDidLoad { NSDictionary *uiKits = [NSDictionary dictionaryWithObject:uiKitList forKey:@"UIKit Animation"]; - [items addObject:uiKits]; + [self.items addObject:uiKits]; self.title = @"Animations"; } @@ -84,18 +86,18 @@ - (void)viewDidLoad { #pragma mark Table view data source - (NSArray *)valuesForSection:(NSUInteger)section { - NSDictionary *dictionary = [items objectAtIndex:section]; + NSDictionary *dictionary = [self.items objectAtIndex:section]; NSString *key = [[dictionary allKeys] objectAtIndex:0]; return [dictionary objectForKey:key]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { - return [[[items objectAtIndex:section] allKeys] objectAtIndex:0]; + return [[[self.items objectAtIndex:section] allKeys] objectAtIndex:0]; } // Customize the number of sections in the table view. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return [items count]; + return [self.items count]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { @@ -109,7 +111,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]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } @@ -126,14 +128,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSArray *values = [self valuesForSection:indexPath.section]; Class clazz = [values objectAtIndex:indexPath.row]; - id controller = [[[clazz alloc] init] autorelease]; + id controller = [[clazz alloc] init]; [self.navigationController pushViewController:controller animated:YES]; } -- (void)dealloc { - CARelease(items); - [super dealloc]; -} - @end - diff --git a/Classes/UIKitAnimation/FlipViewController.h b/Classes/UIKitAnimation/FlipViewController.h index bb59b33..50ae8e4 100644 --- a/Classes/UIKitAnimation/FlipViewController.h +++ b/Classes/UIKitAnimation/FlipViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/Classes/UIKitAnimation/FlipViewController.m b/Classes/UIKitAnimation/FlipViewController.m index a44166f..bc6cca4 100644 --- a/Classes/UIKitAnimation/FlipViewController.m +++ b/Classes/UIKitAnimation/FlipViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -57,8 +57,6 @@ - (void)viewDidLoad { UIGestureRecognizer *backViewTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(flipViews)]; [frontView addGestureRecognizer:frontViewTapRecognizer]; [backView addGestureRecognizer:backViewTapRecognizer]; - [frontViewTapRecognizer release]; - [backViewTapRecognizer release]; } - (void)flipViews { @@ -74,10 +72,7 @@ - (void)flipViews { } - (void)dealloc { - [frontView release]; - [backView release]; [UIApplication sharedApplication].keyWindow.backgroundColor = [UIColor whiteColor]; - [super dealloc]; } diff --git a/Classes/UIKitAnimation/NoteView.h b/Classes/UIKitAnimation/NoteView.h index b0d9a4f..2bb3afd 100644 --- a/Classes/UIKitAnimation/NoteView.h +++ b/Classes/UIKitAnimation/NoteView.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -22,12 +22,9 @@ // THE SOFTWARE. // -@interface NoteView : UIView { - id delegate; - UITextView *textView; -} +@interface NoteView : UIView -@property (nonatomic, assign) id delegate; +@property (nonatomic, weak) id delegate; @property (nonatomic, copy) NSString *text; @end diff --git a/Classes/UIKitAnimation/NoteView.m b/Classes/UIKitAnimation/NoteView.m index 0d4d92b..af5a0f7 100644 --- a/Classes/UIKitAnimation/NoteView.m +++ b/Classes/UIKitAnimation/NoteView.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -24,9 +24,14 @@ #import "NoteView.h" +@interface NoteView () +@property (nonatomic, strong) UITextView *textView; +@end + @implementation NoteView -@synthesize delegate, text; +@synthesize delegate = _delegate; +@synthesize textView = _textView; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; @@ -37,12 +42,12 @@ - (id)initWithFrame:(CGRect)frame { self.layer.borderWidth = 1.0f; // Add Text View - textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 10, self.bounds.size.width - 20, self.bounds.size.height - 44)]; - textView.editable = NO; - textView.font = [UIFont fontWithName:@"Marker Felt" size:36]; - textView.textColor = [UIColor colorWithWhite:0.200 alpha:1.000]; - textView.backgroundColor = [UIColor clearColor]; - [self addSubview:textView]; + self.textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 10, self.bounds.size.width - 20, self.bounds.size.height - 44)]; + self.textView.editable = NO; + self.textView.font = [UIFont fontWithName:@"Marker Felt" size:36]; + self.textView.textColor = [UIColor colorWithWhite:0.200 alpha:1.000]; + self.textView.backgroundColor = [UIColor clearColor]; + [self addSubview:self.textView]; // Add New Button UIImage *newNoteImage = [UIImage imageNamed:@"new_note_icon.png"]; @@ -62,16 +67,12 @@ - (void)addNote { } - (NSString *)text { - return [textView text]; + return [self.textView text]; } - (void)setText:(NSString *)newText { - [textView setText:newText]; + [self.textView setText:newText]; } -- (void)dealloc { - CARelease(textView); - [super dealloc]; -} @end diff --git a/Classes/UIKitAnimation/SimpleViewPropertyAnimation.h b/Classes/UIKitAnimation/SimpleViewPropertyAnimation.h index d603a47..cf66460 100644 --- a/Classes/UIKitAnimation/SimpleViewPropertyAnimation.h +++ b/Classes/UIKitAnimation/SimpleViewPropertyAnimation.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/Classes/UIKitAnimation/SimpleViewPropertyAnimation.m b/Classes/UIKitAnimation/SimpleViewPropertyAnimation.m index ce31b14..86dec74 100644 --- a/Classes/UIKitAnimation/SimpleViewPropertyAnimation.m +++ b/Classes/UIKitAnimation/SimpleViewPropertyAnimation.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -32,7 +32,7 @@ + (NSString *)displayName { } - (UIGestureRecognizer *)createTapRecognizerWithSelector:(SEL)selector { - return [[[UITapGestureRecognizer alloc] initWithTarget:self action:selector] autorelease]; + return [[UITapGestureRecognizer alloc] initWithTarget:self action:selector]; } - (void)viewDidLoad { @@ -64,10 +64,5 @@ - (void)moveMe { }]; } -- (void)dealloc { - CARelease(fadeMeView); - CARelease(moveMeView); - [super dealloc]; -} @end diff --git a/Classes/UIKitAnimation/StickyNotesViewController.h b/Classes/UIKitAnimation/StickyNotesViewController.h index d934ffb..3da0b4e 100644 --- a/Classes/UIKitAnimation/StickyNotesViewController.h +++ b/Classes/UIKitAnimation/StickyNotesViewController.h @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ NSString *nextText; } -@property (nonatomic, retain) NoteView *noteView; +@property (nonatomic, strong) NoteView *noteView; @property (nonatomic, copy) NSString *nextText; @end diff --git a/Classes/UIKitAnimation/StickyNotesViewController.m b/Classes/UIKitAnimation/StickyNotesViewController.m index 01d26d0..09a3468 100644 --- a/Classes/UIKitAnimation/StickyNotesViewController.m +++ b/Classes/UIKitAnimation/StickyNotesViewController.m @@ -1,7 +1,7 @@ // // MIT License // -// Copyright (c) 2011 Bob McCune http://bobmccune.com/ +// Copyright (c) 2012 Bob McCune http://bobmccune.com/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -34,7 +34,7 @@ + (NSString *)displayName { - (void)viewDidLoad { [super viewDidLoad]; self.title = [[self class] displayName]; - self.noteView = [[[NoteView alloc] initWithFrame:CGRectMake(0, 0, 280, 300)] autorelease]; + self.noteView = [[NoteView alloc] initWithFrame:CGRectMake(0, 0, 280, 300)]; self.noteView.delegate = self; self.noteView.text = @"A computer once beat me at chess, but it was no match for me at kick boxing.\n-Emo Philips"; self.nextText = @"A lot of people are afraid of heights. Not me, I'm afraid of widths.\n-Steven Wright"; @@ -44,7 +44,7 @@ - (void)viewDidLoad { // Shadow needs to be applied to the containing layer so it doesn't blip when the animation occurs. // Hat tip to Troy for pointing that out! - UIView *containerView = [[[UIView alloc] initWithFrame:CGRectMake(20, 20, 280, 300)] autorelease]; + UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 280, 300)]; containerView.backgroundColor = [UIColor clearColor]; containerView.layer.shadowOffset = CGSizeMake(0, 2); containerView.layer.shadowOpacity = 0.80; @@ -64,11 +64,6 @@ - (void)addNoteTapped { }]; } -- (void)dealloc { - self.noteView = nil; - self.nextText = nil; - [super dealloc]; -} @synthesize noteView, nextText; diff --git a/CoreAnimation.xcodeproj/project.pbxproj b/CoreAnimation.xcodeproj/project.pbxproj index 2a15e3d..138d847 100755 --- a/CoreAnimation.xcodeproj/project.pbxproj +++ b/CoreAnimation.xcodeproj/project.pbxproj @@ -427,6 +427,7 @@ 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; @@ -442,6 +443,7 @@ 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 = CoreAnimation_Prefix.pch; diff --git a/main.m b/main.m index de3b6fe..61b3608 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, nil); - [pool release]; - return retVal; + @autoreleasepool { + int retVal = UIApplicationMain(argc, argv, nil, nil); + return retVal; + } }