Skip to content

Commit

Permalink
Migrated library and example to iOS 5 automatic reference counting (ARC)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy White committed May 21, 2012
1 parent a373309 commit da0eae7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 58 deletions.
8 changes: 5 additions & 3 deletions example/PRTween.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
B25002B1139558F700670D11 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0420;
LastUpgradeCheck = 0430;
ORGANIZATIONNAME = Jetsetter;
};
buildConfigurationList = B25002B4139558F700670D11 /* Build configuration list for PBXProject "PRTween" */;
Expand Down Expand Up @@ -263,13 +263,14 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PRTween-Prefix.pch";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "PRTween-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
WRAPPER_EXTENSION = app;
Expand All @@ -280,12 +281,13 @@
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 = "PRTween-Prefix.pch";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "PRTween-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.3">
LastUpgradeVersion = "0430"
version = "1.8">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand Down Expand Up @@ -30,13 +31,16 @@
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
displayScaleIsEnabled = "NO"
displayScale = "1.00"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug">
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -55,7 +59,8 @@
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release">
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
Expand Down
7 changes: 0 additions & 7 deletions example/PRTweenExampleAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,4 @@ - (void)applicationWillTerminate:(UIApplication *)application
*/
}

- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}

@end
8 changes: 1 addition & 7 deletions example/PRTweenExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@

@implementation PRTweenExampleViewController

- (void)dealloc
{
[testView release];
[super dealloc];
}

#pragma mark - View lifecycle

- (void)viewDidLoad
Expand Down Expand Up @@ -93,7 +87,7 @@ - (IBAction)shorthandTapped {
- (void)viewDidUnload
{
[super viewDidUnload];
[testView release];
testView = nil;
}

@end
6 changes: 2 additions & 4 deletions example/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
//

#import <UIKit/UIKit.h>
#import "PRTweenExampleAppDelegate.h"

int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
return UIApplicationMain(argc, argv, nil, NSStringFromClass([PRTweenExampleAppDelegate class]));
}
47 changes: 14 additions & 33 deletions lib/PRTween.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ + (id)periodWithStartValue:(CGFloat)aStartValue endValue:(CGFloat)anEndValue dur
period.duration = duration;
period.startOffset = [[PRTween sharedInstance] timeOffset];

return [period autorelease];
return period;
}

@end
Expand All @@ -37,14 +37,7 @@ + (id)periodWithStartValue:(NSValue*)aStartValue endValue:(NSValue*)anEndValue d
period.duration = duration;
period.startOffset = [[PRTween sharedInstance] timeOffset];

return [period autorelease];
}

- (void)dealloc {
[startLerp release];
[endLerp release];
[tweenedLerp release];
[super dealloc];
return period;
}

@end
Expand Down Expand Up @@ -125,17 +118,6 @@ @implementation PRTweenOperation
@synthesize completeBlock;
#endif

- (void)dealloc {
#if NS_BLOCKS_AVAILABLE
[updateBlock release];
[completeBlock release];
#endif
[period release];
[target release];
[boundObject release];
[super dealloc];
}

@end

@implementation PRTweenCGPointLerp
Expand Down Expand Up @@ -211,7 +193,7 @@ + (PRTween *)sharedInstance {
+ (PRTweenOperation *)tween:(id)object property:(NSString*)property from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject*)target completeSelector:(SEL)selector {

PRTweenPeriod *period = [PRTweenPeriod periodWithStartValue:from endValue:to duration:duration];
PRTweenOperation *operation = [[PRTweenOperation new] autorelease];
PRTweenOperation *operation = [PRTweenOperation new];
operation.period = period;
operation.timingFunction = timingFunction;
operation.target = target;
Expand All @@ -229,7 +211,7 @@ + (PRTweenOperation *)tween:(id)object property:(NSString*)property from:(CGFloa
+ (PRTweenOperation *)tween:(CGFloat *)ref from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject*)target completeSelector:(SEL)selector {

PRTweenPeriod *period = [PRTweenPeriod periodWithStartValue:from endValue:to duration:duration];
PRTweenOperation *operation = [[PRTweenOperation new] autorelease];
PRTweenOperation *operation = [PRTweenOperation new];
operation.period = period;
operation.timingFunction = timingFunction;
operation.target = target;
Expand All @@ -253,7 +235,7 @@ + (PRTweenOperation *)tween:(CGFloat *)ref from:(CGFloat)from to:(CGFloat)to dur
+ (PRTweenOperation *)lerp:(id)object property:(NSString *)property period:(PRTweenLerpPeriod <PRTweenLerpPeriod> *)period timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject *)target completeSelector:(SEL)selector {

//PRTweenPeriod *period = [PRTweenLerpPeriod periodWithStartValue:from endValue:to duration:duration];
PRTweenOperation *operation = [[PRTweenOperation new] autorelease];
PRTweenOperation *operation = [PRTweenOperation new];
operation.period = period;
operation.timingFunction = timingFunction;
operation.target = target;
Expand All @@ -272,7 +254,7 @@ + (PRTweenOperation *)lerp:(id)object property:(NSString *)property period:(PRTw
+ (PRTweenOperation *)tween:(id)object property:(NSString*)property from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock {

PRTweenPeriod *period = [PRTweenPeriod periodWithStartValue:from endValue:to duration:duration];
PRTweenOperation *operation = [[PRTweenOperation new] autorelease];
PRTweenOperation *operation = [PRTweenOperation new];
operation.period = period;
operation.timingFunction = timingFunction;
operation.updateBlock = updateBlock;
Expand All @@ -290,7 +272,7 @@ + (PRTweenOperation *)tween:(id)object property:(NSString*)property from:(CGFloa
+ (PRTweenOperation *)tween:(CGFloat *)ref from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock {

PRTweenPeriod *period = [PRTweenPeriod periodWithStartValue:from endValue:to duration:duration];
PRTweenOperation *operation = [[PRTweenOperation new] autorelease];
PRTweenOperation *operation = [PRTweenOperation new];
operation.period = period;
operation.timingFunction = timingFunction;
operation.updateBlock = updateBlock;
Expand All @@ -306,7 +288,7 @@ + (PRTweenOperation *)tween:(CGFloat *)ref from:(CGFloat)from to:(CGFloat)to dur
+ (PRTweenOperation *)lerp:(id)object property:(NSString *)property period:(PRTweenLerpPeriod <PRTweenLerpPeriod> *)period timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock {

//PRTweenPeriod *period = [PRTweenLerpPeriod periodWithStartValue:from endValue:to duration:duration];
PRTweenOperation *operation = [[PRTweenOperation new] autorelease];
PRTweenOperation *operation = [PRTweenOperation new];
operation.period = period;
operation.timingFunction = timingFunction;
operation.updateBlock = updateBlock;
Expand Down Expand Up @@ -534,7 +516,7 @@ - (PRTweenOperation*)addTweenPeriod:(PRTweenPeriod *)period
completionBlock:(void (^)())completeBlock
timingFunction:(PRTweenTimingFunction)timingFunction {

PRTweenOperation *tweenOperation = [[PRTweenOperation new] autorelease];
PRTweenOperation *tweenOperation = [PRTweenOperation new];
tweenOperation.period = period;
tweenOperation.timingFunction = timingFunction;
tweenOperation.updateBlock = anUpdateBlock;
Expand All @@ -550,7 +532,7 @@ - (PRTweenOperation*)addTweenPeriod:(PRTweenPeriod *)period target:(NSObject *)t

- (PRTweenOperation*)addTweenPeriod:(PRTweenPeriod *)period target:(NSObject *)target selector:(SEL)selector timingFunction:(PRTweenTimingFunction)timingFunction {

PRTweenOperation *tweenOperation = [[PRTweenOperation new] autorelease];
PRTweenOperation *tweenOperation = [PRTweenOperation new];
tweenOperation.period = period;
tweenOperation.target = target;
tweenOperation.timingFunction = timingFunction;
Expand Down Expand Up @@ -634,7 +616,7 @@ - (void)update {
}

// clean up expired tween operations
for (PRTweenOperation *tweenOperation in expiredTweenOperations) {
for (__strong PRTweenOperation *tweenOperation in expiredTweenOperations) {

if (tweenOperation.completeSelector) [tweenOperation.target performSelector:tweenOperation.completeSelector withObject:nil afterDelay:0];
// Check to see if blocks/GCD are supported
Expand All @@ -661,11 +643,10 @@ - (void)update {
}

- (void)dealloc {
[tweenOperations release];
[expiredTweenOperations release];
tweenOperations = nil;
expiredTweenOperations = nil;

[timer invalidate];

[super dealloc];
}

@end

0 comments on commit da0eae7

Please sign in to comment.