Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 4.2 Migration #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.2
4 changes: 2 additions & 2 deletions DGElasticPullToRefresh/DGElasticPullToRefreshExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ public extension UIPanGestureRecognizer {
// MARK: -
// MARK: (UIGestureRecognizerState) Extension

public extension UIGestureRecognizerState {
func dg_isAnyOf(_ values: [UIGestureRecognizerState]) -> Bool {
public extension UIGestureRecognizer.State {
func dg_isAnyOf(_ values: [UIGestureRecognizer.State]) -> Bool {
return values.contains(where: { $0 == self })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import UIKit
public extension CGFloat {

public func toRadians() -> CGFloat {
return (self * CGFloat(M_PI)) / 180.0
return (self * CGFloat(Double.pi)) / 180.0
}

public func toDegrees() -> CGFloat {
return self * 180.0 / CGFloat(M_PI)
return self * 180.0 / CGFloat(Double.pi)
}

}
Expand Down Expand Up @@ -99,11 +99,11 @@ open class DGElasticPullToRefreshLoadingViewCircle: DGElasticPullToRefreshLoadin
if shapeLayer.animation(forKey: kRotationAnimation) != nil { return }

let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
rotationAnimation.toValue = CGFloat(2 * M_PI) + currentDegree()
rotationAnimation.toValue = CGFloat(2 * Double.pi) + currentDegree()
rotationAnimation.duration = 1.0
rotationAnimation.repeatCount = Float.infinity
rotationAnimation.isRemovedOnCompletion = false
rotationAnimation.fillMode = kCAFillModeForwards
rotationAnimation.fillMode = CAMediaTimingFillMode.forwards
shapeLayer.add(rotationAnimation, forKey: kRotationAnimation)
}

Expand Down
8 changes: 4 additions & 4 deletions DGElasticPullToRefresh/DGElasticPullToRefreshView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ open class DGElasticPullToRefreshView: UIView {
super.init(frame: CGRect.zero)

displayLink = CADisplayLink(target: self, selector: #selector(DGElasticPullToRefreshView.displayLinkTick))
displayLink.add(to: RunLoop.main, forMode: RunLoopMode.commonModes)
displayLink.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
displayLink.isPaused = true

shapeLayer.backgroundColor = UIColor.clear.cgColor
Expand All @@ -141,7 +141,7 @@ open class DGElasticPullToRefreshView: UIView {
addSubview(r2ControlPointView)
addSubview(r3ControlPointView)

NotificationCenter.default.addObserver(self, selector: #selector(DGElasticPullToRefreshView.applicationWillEnterForeground), name: NSNotification.Name.UIApplicationWillEnterForeground, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(DGElasticPullToRefreshView.applicationWillEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
}

required public init?(coder aDecoder: NSCoder) {
Expand Down Expand Up @@ -193,7 +193,7 @@ open class DGElasticPullToRefreshView: UIView {
// MARK: -
// MARK: Notifications

func applicationWillEnterForeground() {
@objc func applicationWillEnterForeground() {
if state == .loading {
layoutSubviews()
}
Expand Down Expand Up @@ -355,7 +355,7 @@ open class DGElasticPullToRefreshView: UIView {
displayLink.isPaused = true
}

func displayLinkTick() {
@objc func displayLinkTick() {
let width = bounds.width
var height: CGFloat = 0.0

Expand Down
33 changes: 29 additions & 4 deletions DGElasticPullToRefreshExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@
05CD145D1BBE8FEA00AF4030 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = "Danil Gontovnik";
TargetAttributes = {
05CD14641BBE8FEA00AF4030 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0800;
LastSwiftMigration = 1010;
};
};
};
Expand Down Expand Up @@ -190,13 +190,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -223,6 +233,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -235,13 +246,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -260,6 +281,8 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -274,7 +297,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.gatafan.DGElasticPullToRefreshExample;
PRODUCT_NAME = DGElasticPullToRefreshExample;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -287,7 +311,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.gatafan.DGElasticPullToRefreshExample;
PRODUCT_NAME = DGElasticPullToRefreshExample;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>DGElasticPullToRefreshExample.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>