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

Commit

Permalink
swift 4
Browse files Browse the repository at this point in the history
  • Loading branch information
hongxinhope committed Sep 26, 2017
1 parent e37edcb commit 33b67fa
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 48 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.1.1"
github "teambition/RRuleSwift" "0.2.0"
24 changes: 20 additions & 4 deletions RecurrencePicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@
D3BB7F0A1CB4F26A0068A253 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = Teambition;
TargetAttributes = {
D3BB7F121CB4F26A0068A253 = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -291,14 +291,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 @@ -327,6 +333,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -343,14 +350,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 All @@ -372,6 +385,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -399,7 +413,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -422,7 +437,8 @@
PRODUCT_BUNDLE_IDENTIFIER = Teambition.RecurrencePicker;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.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 = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
14 changes: 7 additions & 7 deletions RecurrencePicker/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ internal extension Constant {
return [.monday, .tuesday, .wednesday, .thursday, .friday, .saturday, .sunday]
}()

static func weekdaySymbols(of language: RecurrencePickerLanguage = InternationalControl.sharedControl.language) -> [String] {
static func weekdaySymbols(of language: RecurrencePickerLanguage = InternationalControl.shared.language) -> [String] {
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: language.identifier)
var weekdaySymbols = dateFormatter.weekdaySymbols!
weekdaySymbols.insert(weekdaySymbols.remove(at: 0), at: 6)
return weekdaySymbols
}

static func shortMonthSymbols(of language: RecurrencePickerLanguage = InternationalControl.sharedControl.language) -> [String] {
static func shortMonthSymbols(of language: RecurrencePickerLanguage = InternationalControl.shared.language) -> [String] {
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: language.identifier)
return dateFormatter.shortMonthSymbols
}

static func monthSymbols(of language: RecurrencePickerLanguage = InternationalControl.sharedControl.language) -> [String] {
static func monthSymbols(of language: RecurrencePickerLanguage = InternationalControl.shared.language) -> [String] {
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: language.identifier)
return dateFormatter.monthSymbols
}

static func basicRecurrenceStrings(of language: RecurrencePickerLanguage = InternationalControl.sharedControl.language) -> [String] {
static func basicRecurrenceStrings(of language: RecurrencePickerLanguage = InternationalControl.shared.language) -> [String] {
let internationalControl = InternationalControl(language: language)
return [internationalControl.localizedString("basicRecurrence.never"),
internationalControl.localizedString("basicRecurrence.everyDay"),
Expand All @@ -72,23 +72,23 @@ internal extension Constant {
internationalControl.localizedString("basicRecurrence.everyWeekday"),]
}

static func frequencyStrings(of language: RecurrencePickerLanguage = InternationalControl.sharedControl.language) -> [String] {
static func frequencyStrings(of language: RecurrencePickerLanguage = InternationalControl.shared.language) -> [String] {
let internationalControl = InternationalControl(language: language)
return [internationalControl.localizedString("frequency.daily"),
internationalControl.localizedString("frequency.weekly"),
internationalControl.localizedString("frequency.monthly"),
internationalControl.localizedString("frequency.yearly"),]
}

static func unitStrings(of language: RecurrencePickerLanguage = InternationalControl.sharedControl.language) -> [String] {
static func unitStrings(of language: RecurrencePickerLanguage = InternationalControl.shared.language) -> [String] {
let internationalControl = InternationalControl(language: language)
return [internationalControl.localizedString("unit.day"),
internationalControl.localizedString("unit.week"),
internationalControl.localizedString("unit.month"),
internationalControl.localizedString("unit.year"),]
}

static func pluralUnitStrings(of language: RecurrencePickerLanguage = InternationalControl.sharedControl.language) -> [String] {
static func pluralUnitStrings(of language: RecurrencePickerLanguage = InternationalControl.shared.language) -> [String] {
let internationalControl = InternationalControl(language: language)
return [internationalControl.localizedString("pluralUnit.day"),
internationalControl.localizedString("pluralUnit.week"),
Expand Down
8 changes: 4 additions & 4 deletions RecurrencePicker/InternationalControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public enum RecurrencePickerLanguage {
}

internal func LocalizedString(_ key: String, comment: String? = nil) -> String {
return InternationalControl.sharedControl.localizedString(key, comment: comment)
return InternationalControl.shared.localizedString(key, comment: comment)
}

internal struct InternationalControl {
internal static var sharedControl = InternationalControl()
internal var language: RecurrencePickerLanguage = .english
public struct InternationalControl {
public static var shared = InternationalControl()
public var language: RecurrencePickerLanguage = .english

internal func localizedString(_ key: String, comment: String? = nil) -> String {
let path = Bundle(identifier: "Teambition.RecurrencePicker")?.path(forResource: language.identifier, ofType: "lproj") ?? Bundle.main.path(forResource: language.identifier, ofType: "lproj")
Expand Down
6 changes: 3 additions & 3 deletions RecurrencePicker/RecurrencePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import RRuleSwift
open class RecurrencePicker: UITableViewController {
open var language: RecurrencePickerLanguage = .english {
didSet {
InternationalControl.sharedControl.language = language
InternationalControl.shared.language = language
}
}
open weak var delegate: RecurrencePickerDelegate?
Expand Down Expand Up @@ -53,13 +53,13 @@ open class RecurrencePicker: UITableViewController {
}

// MARK: - Actions
func doneButtonTapped(_ sender: UIBarButtonItem) {
@objc func doneButtonTapped(_ sender: UIBarButtonItem) {
dismiss(animated: true) {
self.recurrencePickerDidPickRecurrence()
}
}

func closeButtonTapped(_ sender: UIBarButtonItem) {
@objc func closeButtonTapped(_ sender: UIBarButtonItem) {
dismiss(animated: true, completion: nil)
}
}
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.sharedControl.language, occurrenceDate: Date) -> String? {
public 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
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.0.7</string>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
20 changes: 17 additions & 3 deletions RecurrencePickerExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = Teambition;
TargetAttributes = {
D3BB7EF31CB4F1820068A253 = {
Expand Down Expand Up @@ -195,14 +195,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 @@ -230,6 +236,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -243,14 +250,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 All @@ -271,6 +284,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -288,7 +302,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Teambition.RecurrencePickerExample;
PRODUCT_NAME = RecurrencePickerExample;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -304,7 +318,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Teambition.RecurrencePickerExample;
PRODUCT_NAME = RecurrencePickerExample;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.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 = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -45,6 +46,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Loading

0 comments on commit 33b67fa

Please sign in to comment.