From 526c36e0d9b06b809c1cac1a7659bee19be17585 Mon Sep 17 00:00:00 2001 From: nathan spindel Date: Mon, 25 Jan 2016 12:58:00 -0800 Subject: [PATCH 1/2] Quelled Xcode 7.2 upgrade warning --- CountingTestProject.xcodeproj/project.pbxproj | 5 ++++- CountingTestProject/CountingTestProject-Info.plist | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CountingTestProject.xcodeproj/project.pbxproj b/CountingTestProject.xcodeproj/project.pbxproj index d9d931c..6dc2659 100644 --- a/CountingTestProject.xcodeproj/project.pbxproj +++ b/CountingTestProject.xcodeproj/project.pbxproj @@ -139,7 +139,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = CTP; - LastUpgradeCheck = 0460; + LastUpgradeCheck = 0720; ORGANIZATIONNAME = "Tim Gostony"; }; buildConfigurationList = 4C5DC29B16C576E30043204D /* Build configuration list for PBXProject "CountingTestProject" */; @@ -222,6 +222,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -271,6 +272,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "CountingTestProject/CountingTestProject-Prefix.pch"; INFOPLIST_FILE = "CountingTestProject/CountingTestProject-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "com.timgostony.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -283,6 +285,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "CountingTestProject/CountingTestProject-Prefix.pch"; INFOPLIST_FILE = "CountingTestProject/CountingTestProject-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "com.timgostony.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; diff --git a/CountingTestProject/CountingTestProject-Info.plist b/CountingTestProject/CountingTestProject-Info.plist index 0f66f26..5860c3f 100644 --- a/CountingTestProject/CountingTestProject-Info.plist +++ b/CountingTestProject/CountingTestProject-Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.timgostony.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName From 59ac84315084bcc0714f6562f423b6d34daddb30 Mon Sep 17 00:00:00 2001 From: nathan spindel Date: Mon, 25 Jan 2016 13:03:17 -0800 Subject: [PATCH 2/2] Replace NSTimer-backed update mechanism with CADisplayLink for more reliable updates --- CountingTestProject.xcodeproj/project.pbxproj | 4 ++++ UICountingLabel.m | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CountingTestProject.xcodeproj/project.pbxproj b/CountingTestProject.xcodeproj/project.pbxproj index 6dc2659..aa4e929 100644 --- a/CountingTestProject.xcodeproj/project.pbxproj +++ b/CountingTestProject.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 33EFDA461C56C4C40084A36A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33EFDA451C56C4C40084A36A /* QuartzCore.framework */; }; 4C5DC2A416C576E30043204D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C5DC2A316C576E30043204D /* UIKit.framework */; }; 4C5DC2A616C576E30043204D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C5DC2A516C576E30043204D /* Foundation.framework */; }; 4C5DC2A816C576E30043204D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C5DC2A716C576E30043204D /* CoreGraphics.framework */; }; @@ -22,6 +23,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 33EFDA451C56C4C40084A36A /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 4C5DC2A016C576E30043204D /* CountingTestProject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CountingTestProject.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4C5DC2A316C576E30043204D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 4C5DC2A516C576E30043204D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -47,6 +49,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 33EFDA461C56C4C40084A36A /* QuartzCore.framework in Frameworks */, 4C5DC2A416C576E30043204D /* UIKit.framework in Frameworks */, 4C5DC2A616C576E30043204D /* Foundation.framework in Frameworks */, 4C5DC2A816C576E30043204D /* CoreGraphics.framework in Frameworks */, @@ -76,6 +79,7 @@ 4C5DC2A216C576E30043204D /* Frameworks */ = { isa = PBXGroup; children = ( + 33EFDA451C56C4C40084A36A /* QuartzCore.framework */, 4C5DC2A316C576E30043204D /* UIKit.framework */, 4C5DC2A516C576E30043204D /* Foundation.framework */, 4C5DC2A716C576E30043204D /* CoreGraphics.framework */, diff --git a/UICountingLabel.m b/UICountingLabel.m index 87bd0cb..cb08010 100755 --- a/UICountingLabel.m +++ b/UICountingLabel.m @@ -1,3 +1,5 @@ +#import + #import "UICountingLabel.h" #if !__has_feature(objc_arc) @@ -86,7 +88,7 @@ @interface UICountingLabel () @property NSTimeInterval totalTime; @property CGFloat easingRate; -@property (nonatomic, weak) NSTimer *timer; +@property (nonatomic, strong) CADisplayLink *timer; @property (nonatomic, strong) id counter; @end @@ -142,9 +144,10 @@ -(void)countFrom:(CGFloat)startValue to:(CGFloat)endValue withDuration:(NSTimeIn break; } - NSTimer *timer = [NSTimer timerWithTimeInterval:(1.0f/30.0f) target:self selector:@selector(updateValue:) userInfo:nil repeats:YES]; - [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; - [[NSRunLoop mainRunLoop] addTimer:timer forMode:UITrackingRunLoopMode]; + CADisplayLink *timer = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateValue:)]; + timer.frameInterval = 2; + [timer addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; + [timer addToRunLoop:[NSRunLoop mainRunLoop] forMode:UITrackingRunLoopMode]; self.timer = timer; }