Skip to content

Commit

Permalink
Merge pull request #480 from CVCalendar/swift4
Browse files Browse the repository at this point in the history
Swift4
  • Loading branch information
Jonas-Taha El Sesiy committed Sep 29, 2017
2 parents ee9b393 + 6d63b5b commit eb60706
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
4 changes: 2 additions & 2 deletions CVCalendar Demo/CVCalendar Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.gameapp.production.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -500,7 +500,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.gameapp.production.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
4 changes: 2 additions & 2 deletions CVCalendar.podspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Pod::Spec.new do |s|

s.name = "CVCalendar"
s.version = "1.5.2"
s.summary = "A custom visual calendar for iOS 8+ written in Swift (3.0)."
s.version = "1.6.0"
s.summary = "A custom visual calendar for iOS 8+ written in Swift (4.0)."
s.homepage = "https://github.com/CVCalendar/CVCalendar"
s.screenshot = "https://raw.githubusercontent.com/Mozharovsky/CVCalendar/master/Screenshots/CVCalendar_White.png"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
24 changes: 19 additions & 5 deletions CVCalendar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = GameApp;
TargetAttributes = {
45D9D8B21C5006AA006673B2 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -322,14 +322,20 @@
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_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_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;
Expand Down Expand Up @@ -372,14 +378,20 @@
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_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_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;
Expand Down Expand Up @@ -425,7 +437,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -445,7 +458,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.gameapp.CVCalendar;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down Expand Up @@ -473,4 +487,4 @@
/* End XCConfigurationList section */
};
rootObject = 45D9D8AA1C5006AA006673B2 /* Project object */;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
14 changes: 7 additions & 7 deletions CVCalendar/CVCalendarContentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ open class CVCalendarContentViewController: UIViewController {
// MARK: - UI Refresh

extension CVCalendarContentViewController {
public func updateFrames(_ frame: CGRect) {
@objc public func updateFrames(_ frame: CGRect) {
if frame != CGRect.zero {
scrollView.frame = frame
scrollView.removeAllSubviews()
Expand Down Expand Up @@ -126,15 +126,15 @@ extension CVCalendarContentViewController: UIScrollViewDelegate { }

// Convenience API.
extension CVCalendarContentViewController {
public func performedDayViewSelection(_ dayView: DayView) { }
@objc public func performedDayViewSelection(_ dayView: DayView) { }

public func togglePresentedDate(_ date: Foundation.Date) { }
@objc public func togglePresentedDate(_ date: Foundation.Date) { }

public func presentNextView(_ view: UIView?) { }
@objc public func presentNextView(_ view: UIView?) { }

public func presentPreviousView(_ view: UIView?) { }
@objc public func presentPreviousView(_ view: UIView?) { }

public func updateDayViews(shouldShow: Bool) { }
@objc public func updateDayViews(shouldShow: Bool) { }
}

// MARK: - Contsant conversion
Expand Down Expand Up @@ -267,4 +267,4 @@ extension UIView {
subview.removeFromSuperview()
}
}
}
}
8 changes: 4 additions & 4 deletions CVCalendar/CVCalendarDayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ extension CVCalendarDayView {

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

public func toDegrees() -> CGFloat {
Expand Down Expand Up @@ -624,12 +624,12 @@ extension CVCalendarDayView {
// MARK: - Safe execution

extension CVCalendarDayView {
public func safeExecuteBlock(_ block: (Void) -> Void, collapsingOnNil collapsing: Bool,
public func safeExecuteBlock(_ block: () -> Void, collapsingOnNil collapsing: Bool,
withObjects objects: AnyObject?...) {
for object in objects {
if object == nil {
if collapsing {
fatalError("Object { \(String(describing: object)) } must not be nil!")
fatalError("Object { \(String(describing: object)) } must not be nil!")
} else {
return
}
Expand All @@ -638,4 +638,4 @@ extension CVCalendarDayView {

block()
}
}
}
22 changes: 11 additions & 11 deletions CVCalendar/CVCalendarMonthView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public final class CVCalendarMonthView: UIView {
extension CVCalendarMonthView {
public func commonInit() {
let calendarManager = calendarView.manager
safeExecuteBlock({
safeExecuteBlock({
let calendar = self.calendarView.delegate?.calendar?() ?? Calendar.current
self.numberOfWeeks = calendarManager?.monthDateRange(self.date).countOfWeeks
self.weeksIn = calendarManager?.weeksWithWeekdaysForMonthDate(self.date).weeksIn
Expand All @@ -94,7 +94,7 @@ extension CVCalendarMonthView {
public func reloadViewsWithRect(_ frame: CGRect) {
self.frame = frame

safeExecuteBlock({
safeExecuteBlock({
for (index, weekView) in self.weekViews.enumerated() {
if let size = self.calendarView.weekViewSize {
weekView.frame = CGRect(x: 0, y: size.height * CGFloat(index),
Expand All @@ -117,11 +117,11 @@ extension CVCalendarMonthView {
public func createWeekViews() {
weekViews = [CVCalendarWeekView]()

safeExecuteBlock({
safeExecuteBlock({
for i in 0..<self.numberOfWeeks! {
let weekView = CVCalendarWeekView(monthView: self, index: i)

self.safeExecuteBlock({
self.safeExecuteBlock({
self.weekViews!.append(weekView)
}, collapsingOnNil: true, withObjects: self.weekViews as AnyObject?)

Expand All @@ -135,7 +135,7 @@ extension CVCalendarMonthView {

extension CVCalendarMonthView {
public func updateInteractiveView() {
safeExecuteBlock({
safeExecuteBlock({
let mode = self.calendarView!.calendarMode!
if mode == .monthView {
if let interactiveView = self.interactiveView {
Expand All @@ -162,7 +162,7 @@ extension CVCalendarMonthView {
}, collapsingOnNil: false, withObjects: calendarView)
}

public func didPressInteractiveView(_ recognizer: UILongPressGestureRecognizer) {
@objc public func didPressInteractiveView(_ recognizer: UILongPressGestureRecognizer) {
let location = recognizer.location(in: self.interactiveView)
let state: UIGestureRecognizerState = recognizer.state

Expand All @@ -181,7 +181,7 @@ extension CVCalendarMonthView {
}
}

public func didTouchInteractiveView(_ recognizer: UITapGestureRecognizer) {
@objc public func didTouchInteractiveView(_ recognizer: UITapGestureRecognizer) {
let location = recognizer.location(in: self.interactiveView)
touchController.receiveTouchLocation(location, inMonthView: self,
withSelectionType: .single)
Expand All @@ -191,18 +191,18 @@ extension CVCalendarMonthView {
// MARK: - Safe execution

extension CVCalendarMonthView {
public func safeExecuteBlock(_ block: (Void) -> Void, collapsingOnNil collapsing: Bool,
public func safeExecuteBlock(_ block: () -> Void, collapsingOnNil collapsing: Bool,
withObjects objects: AnyObject?...) {
for object in objects {
if object == nil {
if collapsing {
fatalError("Object { \(String(describing: object)) } must not be nil!")
fatalError("Object { \(String(describing: object)) } must not be nil!")
} else {
return
}
}
}

block()
block()
}
}
}
16 changes: 8 additions & 8 deletions CVCalendar/CVCalendarWeekView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public final class CVCalendarWeekView: UIView {

extension CVCalendarWeekView {
public func updateInteractiveView() {
safeExecuteBlock({
safeExecuteBlock({

let mode = self.monthView!.calendarView!.calendarMode!
if mode == .weekView {
Expand Down Expand Up @@ -164,7 +164,7 @@ extension CVCalendarWeekView {
}, collapsingOnNil: false, withObjects: monthView, monthView?.calendarView)
}

public func didPressInteractiveView(_ recognizer: UILongPressGestureRecognizer) {
@objc public func didPressInteractiveView(_ recognizer: UILongPressGestureRecognizer) {
let location = recognizer.location(in: self.interactiveView)
let state: UIGestureRecognizerState = recognizer.state

Expand All @@ -183,7 +183,7 @@ extension CVCalendarWeekView {
}
}

public func didTouchInteractiveView(_ recognizer: UITapGestureRecognizer) {
@objc public func didTouchInteractiveView(_ recognizer: UITapGestureRecognizer) {
let location = recognizer.location(in: self.interactiveView)
touchController.receiveTouchLocation(location, inWeekView: self, withSelectionType: .single)
}
Expand All @@ -197,7 +197,7 @@ extension CVCalendarWeekView {
for i in 1...7 {
let dayView = CVCalendarDayView(weekView: self, weekdayIndex: i)

safeExecuteBlock({
safeExecuteBlock({
self.dayViews!.append(dayView)
}, collapsingOnNil: true, withObjects: dayViews as AnyObject?)

Expand All @@ -223,18 +223,18 @@ extension CVCalendarWeekView {
// MARK: - Safe execution

extension CVCalendarWeekView {
public func safeExecuteBlock(_ block: (Void) -> Void, collapsingOnNil collapsing: Bool,
public func safeExecuteBlock(_ block: () -> Void, collapsingOnNil collapsing: Bool,
withObjects objects: AnyObject?...) {
for object in objects {
if object == nil {
if collapsing {
fatalError("Object { \(String(describing: object)) } must not be nil!")
fatalError("Object { \(String(describing: object)) } must not be nil!")
} else {
return
}
}
}

block()
block()
}
}
}

0 comments on commit eb60706

Please sign in to comment.