Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
hongxinhope committed Apr 4, 2019
1 parent 51cbf17 commit b3f759a
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "teambition/RRuleSwift" "0.4.2"
github "teambition/RRuleSwift" "0.5.0"
11 changes: 5 additions & 6 deletions RecurrencePicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,21 @@
TargetAttributes = {
D3BB7F121CB4F26A0068A253 = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = D3BB7F0D1CB4F26A0068A253 /* Build configuration list for PBXProject "RecurrencePicker" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
ja,
ko,
"zh-Hans",
"zh-Hant",
Base,
);
mainGroup = D3BB7F091CB4F26A0068A253;
productRefGroup = D3BB7F141CB4F26A0068A253 /* Products */;
Expand Down Expand Up @@ -417,8 +418,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -441,8 +441,7 @@
PRODUCT_BUNDLE_IDENTIFIER = Teambition.RecurrencePicker;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 3 additions & 3 deletions RecurrencePicker/CustomRecurrenceViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ extension CustomRecurrenceViewController {
if recurrenceRule.byweekday == [weekday] {
return
}
let index = recurrenceRule.byweekday.index(of: weekday)!
let index = recurrenceRule.byweekday.firstIndex(of: weekday)!
recurrenceRule.byweekday.remove(at: index)
cell?.accessoryType = .none
updateRecurrenceRuleText()
Expand Down Expand Up @@ -369,7 +369,7 @@ extension CustomRecurrenceViewController: MonthOrDaySelectorCellDelegate {
tableView.endUpdates()
updateDetailTextColor()
}
if let index = recurrenceRule.bymonthday.index(of: monthday) {
if let index = recurrenceRule.bymonthday.firstIndex(of: monthday) {
recurrenceRule.bymonthday.remove(at: index)
updateRecurrenceRuleText()
}
Expand Down Expand Up @@ -399,7 +399,7 @@ extension CustomRecurrenceViewController: MonthOrDaySelectorCellDelegate {
tableView.endUpdates()
updateDetailTextColor()
}
if let index = recurrenceRule.bymonth.index(of: month) {
if let index = recurrenceRule.bymonth.firstIndex(of: month) {
recurrenceRule.bymonth.remove(at: index)
updateRecurrenceRuleText()
}
Expand Down
2 changes: 1 addition & 1 deletion RecurrencePicker/EKWeekday+Sequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import EventKit

internal extension EKWeekday {
internal var number: Int {
var number: Int {
switch self {
case .monday: return 0
case .tuesday: return 1
Expand Down
4 changes: 2 additions & 2 deletions RecurrencePicker/MonthOrDaySelectorCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ extension MonthOrDaySelectorCell: UICollectionViewDataSource, UICollectionViewDe
let shouldDeselectDay = delegate?.monthOrDaySelectorCell(self, shouldDeselectMonthday: monthday) ?? true
if shouldDeselectDay {
cell.setItemSelected(false)
if let index = bymonthday.index(of: monthday) {
if let index = bymonthday.firstIndex(of: monthday) {
bymonthday.remove(at: index)
}
delegate?.monthOrDaySelectorCell(self, didDeselectMonthday: monthday)
Expand All @@ -179,7 +179,7 @@ extension MonthOrDaySelectorCell: UICollectionViewDataSource, UICollectionViewDe
let shouldDeselectMonth = delegate?.monthOrDaySelectorCell(self, shouldDeselectMonth: month) ?? true
if shouldDeselectMonth {
cell.setItemSelected(false)
if let index = bymonth.index(of: month) {
if let index = bymonth.firstIndex(of: month) {
bymonth.remove(at: index)
}
delegate?.monthOrDaySelectorCell(self, didDeselectMonth: month)
Expand Down
2 changes: 1 addition & 1 deletion RecurrencePicker/RecurrenceFrequency+Sequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import RRuleSwift

internal extension RecurrenceFrequency {
internal var number: Int {
var number: Int {
switch self {
case .daily: return 0
case .weekly: return 1
Expand Down
14 changes: 7 additions & 7 deletions RecurrencePicker/RecurrenceRule+Definition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import Foundation
import RRuleSwift

public extension RecurrenceRule {
public func isDailyRecurrence() -> Bool {
func isDailyRecurrence() -> Bool {
return frequency == .daily && interval == 1
}

public func isWeekdayRecurrence() -> Bool {
func isWeekdayRecurrence() -> Bool {
guard frequency == .weekly && interval == 1 else {
return false
}
let byweekday = self.byweekday.sorted(by: <)
return byweekday == [.monday, .tuesday, .wednesday, .thursday, .friday].sorted(by: <)
}

public func isWeeklyRecurrence(occurrence occurrenceDate: Date) -> Bool {
func isWeeklyRecurrence(occurrence occurrenceDate: Date) -> Bool {
guard frequency == .weekly && interval == 1 else {
return false
}
Expand All @@ -36,7 +36,7 @@ public extension RecurrenceRule {
return calendar.component(.weekday, from: occurrenceDate) == weekday.rawValue
}

public func isBiWeeklyRecurrence(occurrence occurrenceDate: Date) -> Bool {
func isBiWeeklyRecurrence(occurrence occurrenceDate: Date) -> Bool {
guard frequency == .weekly && interval == 2 else {
return false
}
Expand All @@ -50,7 +50,7 @@ public extension RecurrenceRule {
return calendar.component(.weekday, from: occurrenceDate) == weekday.rawValue
}

public func isMonthlyRecurrence(occurrence occurrenceDate: Date) -> Bool {
func isMonthlyRecurrence(occurrence occurrenceDate: Date) -> Bool {
guard frequency == .monthly && interval == 1 else {
return false
}
Expand All @@ -64,7 +64,7 @@ public extension RecurrenceRule {
return calendar.component(.day, from: occurrenceDate) == monthday
}

public func isYearlyRecurrence(occurrence occurrenceDate: Date) -> Bool {
func isYearlyRecurrence(occurrence occurrenceDate: Date) -> Bool {
guard frequency == .yearly && interval == 1 else {
return false
}
Expand All @@ -78,7 +78,7 @@ public extension RecurrenceRule {
return calendar.component(.month, from: occurrenceDate) == month
}

public func isCustomRecurrence(occurrence occurrenceDate: Date) -> Bool {
func isCustomRecurrence(occurrence occurrenceDate: Date) -> Bool {
return !isDailyRecurrence() &&
!isWeekdayRecurrence() &&
!isWeeklyRecurrence(occurrence: occurrenceDate) &&
Expand Down
12 changes: 6 additions & 6 deletions RecurrencePicker/RecurrenceRule+Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ import EventKit
import RRuleSwift

public extension RecurrenceRule {
public static func dailyRecurrence() -> RecurrenceRule {
static func dailyRecurrence() -> RecurrenceRule {
var recurrenceRule = RecurrenceRule(frequency: .daily)
recurrenceRule.interval = 1
return recurrenceRule
}

public static func weekdayRecurrence() -> RecurrenceRule {
static func weekdayRecurrence() -> RecurrenceRule {
var recurrenceRule = RecurrenceRule(frequency: .weekly)
recurrenceRule.interval = 1
recurrenceRule.byweekday = [.monday, .tuesday, .wednesday, .thursday, .friday]
return recurrenceRule
}

public static func weeklyRecurrence(withWeekday weekday: EKWeekday) -> RecurrenceRule {
static func weeklyRecurrence(withWeekday weekday: EKWeekday) -> RecurrenceRule {
var recurrenceRule = RecurrenceRule(frequency: .weekly)
recurrenceRule.interval = 1
recurrenceRule.byweekday = [weekday]
return recurrenceRule
}

public static func biWeeklyRecurrence(withWeekday weekday: EKWeekday) -> RecurrenceRule {
static func biWeeklyRecurrence(withWeekday weekday: EKWeekday) -> RecurrenceRule {
var recurrenceRule = RecurrenceRule(frequency: .weekly)
recurrenceRule.interval = 2
recurrenceRule.byweekday = [weekday]
return recurrenceRule
}

public static func monthlyRecurrence(withMonthday monthday: Int) -> RecurrenceRule {
static func monthlyRecurrence(withMonthday monthday: Int) -> RecurrenceRule {
var recurrenceRule = RecurrenceRule(frequency: .monthly)
recurrenceRule.interval = 1
if (-31...31 ~= monthday) && (monthday != 0) {
Expand All @@ -47,7 +47,7 @@ public extension RecurrenceRule {
return recurrenceRule
}

public static func yearlyRecurrence(withMonth month: Int) -> RecurrenceRule {
static func yearlyRecurrence(withMonth month: Int) -> RecurrenceRule {
var recurrenceRule = RecurrenceRule(frequency: .yearly)
recurrenceRule.interval = 1
if 1...12 ~= month {
Expand Down
2 changes: 1 addition & 1 deletion RecurrencePicker/RecurrenceRule+Text.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import RRuleSwift

public extension RecurrenceRule {
public func toText(of language: RecurrencePickerLanguage = InternationalControl.shared.language, occurrenceDate: Date) -> String? {
func toText(of language: RecurrencePickerLanguage = InternationalControl.shared.language, occurrenceDate: Date) -> String? {
let internationalControl = InternationalControl(language: language)
let unit = Constant.unitStrings(of: language)[frequency.number]
let pluralUnit = Constant.pluralUnitStrings(of: language)[frequency.number]
Expand Down
4 changes: 2 additions & 2 deletions RecurrencePicker/String+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import Foundation

internal extension String {
internal mutating func removeSubstring(_ substring: String) {
mutating func removeSubstring(_ substring: String) {
self = replacingOccurrences(of: substring, with: "", options: .literal, range: nil)
}

internal static func sequenceNumberString(of number: Int) -> String {
static func sequenceNumberString(of number: Int) -> String {
var suffix = "th"
let ones = number % 10
let tens = (number / 10) % 10
Expand Down
2 changes: 1 addition & 1 deletion RecurrencePicker/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1.3</string>
<string>0.1.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
12 changes: 7 additions & 5 deletions RecurrencePickerExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = Teambition;
TargetAttributes = {
D3BB7EF31CB4F1820068A253 = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0800;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = D3BB7EEF1CB4F1820068A253 /* Build configuration list for PBXProject "RecurrencePickerExample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -190,6 +190,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -247,6 +248,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -306,7 +308,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Teambition.RecurrencePickerExample;
PRODUCT_NAME = RecurrencePickerExample;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -322,7 +324,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Teambition.RecurrencePickerExample;
PRODUCT_NAME = RecurrencePickerExample;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -30,6 +40,16 @@
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
Expand Down Expand Up @@ -64,6 +84,11 @@
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
2 changes: 1 addition & 1 deletion RecurrencePickerExample/ExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ExampleViewController: UIViewController {

// MARK: - Helper
fileprivate func updateLanguageButtonTitle() {
guard let index = languages.index(of: language) else {
guard let index = languages.firstIndex(of: language) else {
return
}
let languageTitle = languageStrings[index]
Expand Down
4 changes: 2 additions & 2 deletions RecurrencePickerExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.3</string>
<string>0.1.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>11</string>
<string>12</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down

0 comments on commit b3f759a

Please sign in to comment.