diff --git a/Alerts&Pickers.xcodeproj/project.pbxproj b/Alerts&Pickers.xcodeproj/project.pbxproj
index 770321c2..0ef42a67 100644
--- a/Alerts&Pickers.xcodeproj/project.pbxproj
+++ b/Alerts&Pickers.xcodeproj/project.pbxproj
@@ -513,7 +513,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
- LastUpgradeCheck = 0920;
+ LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Supreme Apps";
TargetAttributes = {
FA3BB2722008B41B00E06F8F = {
@@ -649,6 +649,7 @@
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_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -656,6 +657,7 @@
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;
@@ -683,9 +685,9 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
- ONLY_ACTIVE_ARCH = NO;
+ ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -707,6 +709,7 @@
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_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -714,6 +717,7 @@
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;
@@ -735,7 +739,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -749,12 +753,12 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
- DEVELOPMENT_TEAM = XL743FKK28;
+ DEVELOPMENT_TEAM = J4L8256R9V;
INFOPLIST_FILE = "$(SRCROOT)/Example/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "AA.Alerts-Pickers";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -764,12 +768,12 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
- DEVELOPMENT_TEAM = XL743FKK28;
+ DEVELOPMENT_TEAM = J4L8256R9V;
INFOPLIST_FILE = "$(SRCROOT)/Example/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "AA.Alerts-Pickers";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
diff --git a/Alerts&Pickers.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Alerts&Pickers.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 00000000..18d98100
--- /dev/null
+++ b/Alerts&Pickers.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/Alerts&Pickers.xcodeproj/xcshareddata/xcschemes/iPhone X.xcscheme b/Alerts&Pickers.xcodeproj/xcshareddata/xcschemes/iPhone X.xcscheme
index 477a9fce..530419db 100644
--- a/Alerts&Pickers.xcodeproj/xcshareddata/xcschemes/iPhone X.xcscheme
+++ b/Alerts&Pickers.xcodeproj/xcshareddata/xcschemes/iPhone X.xcscheme
@@ -1,6 +1,6 @@
@@ -46,7 +45,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
diff --git a/Example/AppDelegate.swift b/Example/AppDelegate.swift
index e1a46626..4c5c9e78 100644
--- a/Example/AppDelegate.swift
+++ b/Example/AppDelegate.swift
@@ -5,7 +5,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = UINavigationController(rootViewController: ViewController())
window?.makeKeyAndVisible()
diff --git a/Example/FlowLayouts/VegaScrollFlowLayout.swift b/Example/FlowLayouts/VegaScrollFlowLayout.swift
index 1008a30f..a0de54a3 100755
--- a/Example/FlowLayouts/VegaScrollFlowLayout.swift
+++ b/Example/FlowLayouts/VegaScrollFlowLayout.swift
@@ -120,7 +120,7 @@ open class VerticalScrollFlowLayout: UICollectionViewFlowLayout {
let touchLocation = collectionView!.panGestureRecognizer.location(in: collectionView)
- dynamicAnimator.behaviors.flatMap { $0 as? UIAttachmentBehavior }.forEach { behavior in
+ dynamicAnimator.behaviors.compactMap { $0 as? UIAttachmentBehavior }.forEach { behavior in
let attrs = behavior.items.first as! UICollectionViewLayoutAttributes
attrs.center = getUpdatedBehaviorItemCenter(behavior: behavior, touchLocation: touchLocation)
self.dynamicAnimator.updateItem(usingCurrentState: attrs)
@@ -168,8 +168,8 @@ open class VerticalScrollFlowLayout: UICollectionViewFlowLayout {
}
private func getUpdatedBehaviorItemCenter(behavior: UIAttachmentBehavior,touchLocation: CGPoint) -> CGPoint {
- let yDistanceFromTouch = fabs(touchLocation.y - behavior.anchorPoint.y)
- let xDistanceFromTouch = fabs(touchLocation.x - behavior.anchorPoint.x)
+ let yDistanceFromTouch = abs(touchLocation.y - behavior.anchorPoint.y)
+ let xDistanceFromTouch = abs(touchLocation.x - behavior.anchorPoint.x)
let scrollResistance = (yDistanceFromTouch + xDistanceFromTouch) / (springHardness * 100)
let attrs = behavior.items.first as! UICollectionViewLayoutAttributes
diff --git a/Example/ViewController.swift b/Example/ViewController.swift
index 09376c63..1e87b27c 100644
--- a/Example/ViewController.swift
+++ b/Example/ViewController.swift
@@ -99,7 +99,7 @@ class ViewController: UIViewController {
// MARK: Properties
- fileprivate var alertStyle: UIAlertControllerStyle = .actionSheet
+ fileprivate var alertStyle: UIAlertController.Style = .actionSheet
fileprivate lazy var segments: SegmentedControl = {
let styles: [String] = ["Alert", "ActionSheet"]
@@ -120,7 +120,7 @@ class ViewController: UIViewController {
$0.register(TypeOneCell.self, forCellWithReuseIdentifier: TypeOneCell.identifier)
$0.showsVerticalScrollIndicator = false
$0.showsHorizontalScrollIndicator = false
- $0.decelerationRate = UIScrollViewDecelerationRateFast
+ $0.decelerationRate = UIScrollView.DecelerationRate.fast
//$0.contentInsetAdjustmentBehavior = .never
$0.bounces = true
$0.backgroundColor = .white
@@ -293,7 +293,7 @@ class ViewController: UIViewController {
let frameSizes: [CGFloat] = (150...300).map { CGFloat($0) }
let pickerViewValues: [[String]] = [frameSizes.map { Int($0).description }]
- let pickerViewSelectedValue: PickerViewViewController.Index = (column: 0, row: frameSizes.index(of: 216) ?? 0)
+ let pickerViewSelectedValue: PickerViewViewController.Index = (column: 0, row: frameSizes.firstIndex(of: 216) ?? 0)
alert.addPickerView(values: pickerViewValues, initialSelection: pickerViewSelectedValue) { vc, picker, index, values in
diff --git a/Source/Extensions/Array+Extensions.swift b/Source/Extensions/Array+Extensions.swift
index 97fdf5de..f47621e9 100644
--- a/Source/Extensions/Array+Extensions.swift
+++ b/Source/Extensions/Array+Extensions.swift
@@ -109,14 +109,14 @@ extension Array where Element: Equatable {
public extension Array {
/// Random item from array.
- public var randomItem: Element? {
+ var randomItem: Element? {
if self.isEmpty { return nil }
let index = Int(arc4random_uniform(UInt32(count)))
return self[index]
}
/// Shuffled version of array.
- public var shuffled: [Element] {
+ var shuffled: [Element] {
var arr = self
for _ in 0..<10 {
arr.sort { (_,_) in arc4random() < arc4random() }
@@ -125,7 +125,7 @@ public extension Array {
}
/// Shuffle array.
- public mutating func shuffle() {
+ mutating func shuffle() {
// https://gist.github.com/ijoshsmith/5e3c7d8c2099a3fe8dc3
for _ in 0..<10 {
sort { (_,_) in arc4random() < arc4random() }
@@ -136,7 +136,7 @@ public extension Array {
///
/// - Parameter index: index of element.
/// - Returns: optional element (if exists).
- public func item(at index: Int) -> Element? {
+ func item(at index: Int) -> Element? {
guard index >= 0 && index < count else { return nil }
return self[index]
}
diff --git a/Source/Extensions/Date+Extension.swift b/Source/Extensions/Date+Extension.swift
index 279b7ca2..04c5dc98 100644
--- a/Source/Extensions/Date+Extension.swift
+++ b/Source/Extensions/Date+Extension.swift
@@ -3,17 +3,17 @@ import Foundation
public extension Date {
/// User’s current calendar.
- public var calendar: Calendar {
+ var calendar: Calendar {
return Calendar.current
}
/// Era.
- public var era: Int {
+ var era: Int {
return calendar.component(.era, from: self)
}
/// Year.
- public var year: Int {
+ var year: Int {
get {
return calendar.component(.year, from: self)
}
@@ -23,12 +23,12 @@ public extension Date {
}
/// Quarter.
- public var quarter: Int {
+ var quarter: Int {
return calendar.component(.quarter, from: self)
}
/// Month.
- public var month: Int {
+ var month: Int {
get {
return calendar.component(.month, from: self)
}
@@ -38,22 +38,22 @@ public extension Date {
}
/// Week of year.
- public var weekOfYear: Int {
+ var weekOfYear: Int {
return calendar.component(.weekOfYear, from: self)
}
/// Week of month.
- public var weekOfMonth: Int {
+ var weekOfMonth: Int {
return calendar.component(.weekOfMonth, from: self)
}
/// Weekday.
- public var weekday: Int {
+ var weekday: Int {
return calendar.component(.weekday, from: self)
}
/// Day.
- public var day: Int {
+ var day: Int {
get {
return calendar.component(.day, from: self)
}
@@ -63,7 +63,7 @@ public extension Date {
}
/// Hour.
- public var hour: Int {
+ var hour: Int {
get {
return calendar.component(.hour, from: self)
}
@@ -73,7 +73,7 @@ public extension Date {
}
/// Minutes.
- public var minute: Int {
+ var minute: Int {
get {
return calendar.component(.minute, from: self)
}
@@ -83,7 +83,7 @@ public extension Date {
}
/// Seconds.
- public var second: Int {
+ var second: Int {
get {
return calendar.component(.second, from: self)
}
@@ -93,27 +93,27 @@ public extension Date {
}
/// Nanoseconds.
- public var nanosecond: Int {
+ var nanosecond: Int {
return calendar.component(.nanosecond, from: self)
}
/// Check if date is in future.
- public var isInFuture: Bool {
+ var isInFuture: Bool {
return self > Date()
}
/// Check if date is in past.
- public var isInPast: Bool {
+ var isInPast: Bool {
return self < Date()
}
/// Check if date is in today.
- public var isInToday: Bool {
+ var isInToday: Bool {
return self.day == Date().day && self.month == Date().month && self.year == Date().year
}
/// ISO8601 string of format (yyyy-MM-dd'T'HH:mm:ss.SSS) from date.
- public var iso8601String: String {
+ var iso8601String: String {
// https://github.com/justinmakaila/NSDate-ISO-8601/blob/master/NSDateISO8601.swift
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
@@ -124,7 +124,7 @@ public extension Date {
}
/// Nearest five minutes to date.
- public var nearestFiveMinutes: Date {
+ var nearestFiveMinutes: Date {
var components = Calendar.current.dateComponents([.year, .month , .day , .hour , .minute], from: self)
guard let min = components.minute else {
return self
@@ -138,7 +138,7 @@ public extension Date {
}
/// Nearest ten minutes to date.
- public var nearestTenMinutes: Date {
+ var nearestTenMinutes: Date {
var components = Calendar.current.dateComponents([.year, .month , .day , .hour , .minute], from: self)
guard let min = components.minute else {
return self
@@ -152,7 +152,7 @@ public extension Date {
}
/// Nearest quarter to date.
- public var nearestHourQuarter: Date {
+ var nearestHourQuarter: Date {
var components = Calendar.current.dateComponents([.year, .month , .day , .hour , .minute], from: self)
guard let min = components.minute else {
return self
@@ -166,7 +166,7 @@ public extension Date {
}
/// Nearest half hour to date.
- public var nearestHalfHour: Date {
+ var nearestHalfHour: Date {
var components = Calendar.current.dateComponents([.year, .month , .day , .hour , .minute], from: self)
guard let min = components.minute else {
return self
@@ -180,12 +180,12 @@ public extension Date {
}
/// Time zone used by system.
- public var timeZone: TimeZone {
+ var timeZone: TimeZone {
return self.calendar.timeZone
}
/// UNIX timestamp from date.
- public var unixTimestamp: Double {
+ var unixTimestamp: Double {
return timeIntervalSince1970
}
@@ -200,7 +200,7 @@ public extension Date {
/// - Parameters:
/// - component: component type.
/// - value: multiples of compnenet to add.
- public mutating func add(_ component: Calendar.Component, value: Int) {
+ mutating func add(_ component: Calendar.Component, value: Int) {
switch component {
case .second:
self = calendar.date(byAdding: .second, value: value, to: self) ?? self
@@ -241,7 +241,7 @@ public extension Date {
/// - component: component type.
/// - value: multiples of compnenets to add.
/// - Returns: original date + multiples of compnenet added.
- public func adding(_ component: Calendar.Component, value: Int) -> Date {
+ func adding(_ component: Calendar.Component, value: Int) -> Date {
switch component {
case .second:
return calendar.date(byAdding: .second, value: value, to: self) ?? self
@@ -275,7 +275,7 @@ public extension Date {
/// - component: component type.
/// - value: new value of compnenet to change.
/// - Returns: original date + multiples of compnenets added.
- public func changing(_ component: Calendar.Component, value: Int) -> Date {
+ func changing(_ component: Calendar.Component, value: Int) -> Date {
switch component {
case .second:
var date = self
@@ -316,7 +316,7 @@ public extension Date {
///
/// - Parameter component: calendar component to get date at the beginning of.
/// - Returns: date at the beginning of calendar component (if applicable).
- public func beginning(of component: Calendar.Component) -> Date? {
+ func beginning(of component: Calendar.Component) -> Date? {
switch component {
case .second:
return calendar.date(from: calendar.dateComponents([.year, .month, .day, .hour, .minute, .second], from: self))
@@ -348,7 +348,7 @@ public extension Date {
///
/// - Parameter component: calendar component to get date at the end of.
/// - Returns: date at the end of calendar component (if applicable).
- public func end(of component: Calendar.Component) -> Date? {
+ func end(of component: Calendar.Component) -> Date? {
switch component {
case .second:
var date = self.adding(.second, value: 1)
@@ -425,7 +425,7 @@ public extension Date {
///
/// - Parameter style: DateFormatter style (default is .medium)
/// - Returns: date and time string
- public func dateTimeString(ofStyle style: DateFormatter.Style = .medium) -> String {
+ func dateTimeString(ofStyle style: DateFormatter.Style = .medium) -> String {
let dateFormatter = DateFormatter()
dateFormatter.timeStyle = style
dateFormatter.dateStyle = style
@@ -436,7 +436,7 @@ public extension Date {
///
/// - Parameter component: calendar componenet to check.
/// - Returns: true if date is in current given calendar component.
- public func isInCurrent(_ component: Calendar.Component) -> Bool {
+ func isInCurrent(_ component: Calendar.Component) -> Bool {
switch component {
case .second:
return second == Date().second && minute == Date().minute && hour == Date().hour && day == Date().day
@@ -473,7 +473,7 @@ public extension Date {
}
/// Time string from date
- public func timeString(ofStyle style: DateFormatter.Style = .medium) -> String {
+ func timeString(ofStyle style: DateFormatter.Style = .medium) -> String {
let dateFormatter = DateFormatter()
dateFormatter.timeStyle = style
dateFormatter.dateStyle = .none
@@ -499,7 +499,7 @@ public extension Date {
/// - minute: Minute (default is current minute).
/// - second: Second (default is current second).
/// - nanosecond: Nanosecond (default is current nanosecond).
- public init(
+ init(
calendar: Calendar? = Calendar.current,
timeZone: TimeZone? = TimeZone.current,
era: Int? = Date().era,
@@ -529,7 +529,7 @@ public extension Date {
/// Create date object from ISO8601 string.
///
/// - Parameter iso8601String: ISO8601 string of format (yyyy-MM-dd'T'HH:mm:ss.SSSZ).
- public init(iso8601String: String) {
+ init(iso8601String: String) {
// https://github.com/justinmakaila/NSDate-ISO-8601/blob/master/NSDateISO8601.swift
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
@@ -541,7 +541,7 @@ public extension Date {
/// Create new date object from UNIX timestamp.
///
/// - Parameter unixTimestamp: UNIX timestamp.
- public init(unixTimestamp: Double) {
+ init(unixTimestamp: Double) {
self.init(timeIntervalSince1970: unixTimestamp)
}
@@ -549,7 +549,7 @@ public extension Date {
public extension Date {
/// SwiftRandom extension
- public static func randomWithinDaysBeforeToday(_ days: Int) -> Date {
+ static func randomWithinDaysBeforeToday(_ days: Int) -> Date {
let today = Date()
let gregorian = Calendar(identifier: Calendar.Identifier.gregorian)
@@ -572,7 +572,7 @@ public extension Date {
}
/// SwiftRandom extension
- public static func random() -> Date {
+ static func random() -> Date {
let randomTime = TimeInterval(arc4random_uniform(UInt32.max))
return Date(timeIntervalSince1970: randomTime)
}
diff --git a/Source/Extensions/String+Extensions.swift b/Source/Extensions/String+Extensions.swift
index e982124d..402e9a3a 100644
--- a/Source/Extensions/String+Extensions.swift
+++ b/Source/Extensions/String+Extensions.swift
@@ -10,11 +10,11 @@ extension String {
return String(self[i] as Character)
}
- subscript (r: Range) -> String {
- let start = index(startIndex, offsetBy: r.lowerBound)
- let end = index(startIndex, offsetBy: r.upperBound)
- return String(self[Range(start ..< end)])
- }
+// subscript (r: Range) -> String {
+// let start = index(startIndex, offsetBy: r.lowerBound)
+// let end = index(startIndex, offsetBy: r.upperBound)
+// return String(self[Range(start ..< end)])
+// }
var containsAlphabets: Bool {
//Checks if all the characters inside the string are alphabets
@@ -30,27 +30,27 @@ extension String {
public extension String {
/// Regular string.
- public var regular: NSAttributedString {
+ var regular: NSAttributedString {
return NSMutableAttributedString(string: self, attributes: [.font: UIFont.systemFont(ofSize: UIFont.systemFontSize)])
}
/// Bold string.
- public var bold: NSAttributedString {
+ var bold: NSAttributedString {
return NSMutableAttributedString(string: self, attributes: [.font: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)])
}
/// Underlined string
- public var underline: NSAttributedString {
- return NSAttributedString(string: self, attributes: [.underlineStyle: NSUnderlineStyle.styleSingle.rawValue])
+ var underline: NSAttributedString {
+ return NSAttributedString(string: self, attributes: [.underlineStyle: NSUnderlineStyle.single.rawValue])
}
/// Strikethrough string.
- public var strikethrough: NSAttributedString {
- return NSAttributedString(string: self, attributes: [.strikethroughStyle: NSNumber(value: NSUnderlineStyle.styleSingle.rawValue as Int)])
+ var strikethrough: NSAttributedString {
+ return NSAttributedString(string: self, attributes: [.strikethroughStyle: NSNumber(value: NSUnderlineStyle.single.rawValue as Int)])
}
/// Italic string.
- public var italic: NSAttributedString {
+ var italic: NSAttributedString {
return NSMutableAttributedString(string: self, attributes: [.font: UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)])
}
@@ -58,7 +58,7 @@ public extension String {
///
/// - Parameter color: text color.
/// - Returns: a NSAttributedString versions of string colored with given color.
- public func colored(with color: UIColor) -> NSAttributedString {
+ func colored(with color: UIColor) -> NSAttributedString {
return NSMutableAttributedString(string: self, attributes: [.foregroundColor: color])
}
}
diff --git a/Source/Extensions/UIAlertController+Extensions.swift b/Source/Extensions/UIAlertController+Extensions.swift
index 8ca0f37c..ad599943 100644
--- a/Source/Extensions/UIAlertController+Extensions.swift
+++ b/Source/Extensions/UIAlertController+Extensions.swift
@@ -12,7 +12,7 @@ extension UIAlertController {
/// - message: alert controller's message (default is nil).
/// - defaultActionButtonTitle: default action button title (default is "OK")
/// - tintColor: alert controller's tint color (default is nil)
- convenience init(style: UIAlertControllerStyle, source: UIView? = nil, title: String? = nil, message: String? = nil, tintColor: UIColor? = nil) {
+ convenience init(style: UIAlertController.Style, source: UIView? = nil, title: String? = nil, message: String? = nil, tintColor: UIColor? = nil) {
self.init(title: title, message: message, preferredStyle: style)
// TODO: for iPad or other views
@@ -48,7 +48,7 @@ extension UIAlertController {
/// - animated: set true to animate presentation of alert controller (default is true).
/// - vibrate: set true to vibrate the device while presenting the alert (default is false).
/// - completion: an optional completion handler to be called after presenting alert controller (default is nil).
- public func show(animated: Bool = true, vibrate: Bool = false, style: UIBlurEffectStyle? = nil, completion: (() -> Void)? = nil) {
+ public func show(animated: Bool = true, vibrate: Bool = false, style: UIBlurEffect.Style? = nil, completion: (() -> Void)? = nil) {
/// TODO: change UIBlurEffectStyle
if let style = style {
@@ -72,7 +72,7 @@ extension UIAlertController {
/// - style: action style (default is UIAlertActionStyle.default)
/// - isEnabled: isEnabled status for action (default is true)
/// - handler: optional action handler to be called when button is tapped (default is nil)
- func addAction(image: UIImage? = nil, title: String, color: UIColor? = nil, style: UIAlertActionStyle = .default, isEnabled: Bool = true, handler: ((UIAlertAction) -> Void)? = nil) {
+ func addAction(image: UIImage? = nil, title: String, color: UIColor? = nil, style: UIAlertAction.Style = .default, isEnabled: Bool = true, handler: ((UIAlertAction) -> Void)? = nil) {
//let isPad: Bool = UIDevice.current.userInterfaceIdiom == .pad
//let action = UIAlertAction(title: title, style: isPad && style == .cancel ? .default : style, handler: handler)
let action = UIAlertAction(title: title, style: style, handler: handler)
@@ -106,7 +106,7 @@ extension UIAlertController {
func setTitle(font: UIFont, color: UIColor) {
guard let title = self.title else { return }
- let attributes: [NSAttributedStringKey: Any] = [.font: font, .foregroundColor: color]
+ let attributes: [NSAttributedString.Key: Any] = [.font: font, .foregroundColor: color]
let attributedTitle = NSMutableAttributedString(string: title, attributes: attributes)
setValue(attributedTitle, forKey: "attributedTitle")
}
@@ -126,7 +126,7 @@ extension UIAlertController {
func setMessage(font: UIFont, color: UIColor) {
guard let message = self.message else { return }
- let attributes: [NSAttributedStringKey: Any] = [.font: font, .foregroundColor: color]
+ let attributes: [NSAttributedString.Key: Any] = [.font: font, .foregroundColor: color]
let attributedMessage = NSMutableAttributedString(string: message, attributes: attributes)
setValue(attributedMessage, forKey: "attributedMessage")
}
diff --git a/Source/Extensions/UIColor+Extensions.swift b/Source/Extensions/UIColor+Extensions.swift
index 62747ece..000d2799 100644
--- a/Source/Extensions/UIColor+Extensions.swift
+++ b/Source/Extensions/UIColor+Extensions.swift
@@ -146,7 +146,7 @@ public extension UIColor {
/// - green: green component.
/// - blue: blue component.
/// - transparency: optional transparency value (default is 1)
- public convenience init(red: Int, green: Int, blue: Int, transparency: CGFloat = 1) {
+ convenience init(red: Int, green: Int, blue: Int, transparency: CGFloat = 1) {
assert(red >= 0 && red <= 255, "Invalid red component")
assert(green >= 0 && green <= 255, "Invalid green component")
assert(blue >= 0 && blue <= 255, "Invalid blue component")
diff --git a/Source/Extensions/UIImageView+Extensions.swift b/Source/Extensions/UIImageView+Extensions.swift
index 3a44b706..5123efbe 100644
--- a/Source/Extensions/UIImageView+Extensions.swift
+++ b/Source/Extensions/UIImageView+Extensions.swift
@@ -9,7 +9,7 @@ extension UIImageView {
/// - color: This optional paramter sets the background of the image. By default, a random color will be generated.
/// - circular: This boolean will determine if the image view will be clipped to a circular shape.
/// - textAttributes: This dictionary allows you to specify font, text color, shadow properties, etc.
- open func setImage(string: String?, color: UIColor? = nil, circular: Bool = false, textAttributes: [NSAttributedStringKey: Any]? = nil) {
+ open func setImage(string: String?, color: UIColor? = nil, circular: Bool = false, textAttributes: [NSAttributedString.Key: Any]? = nil) {
let image = imageSnap(text: string != nil ? string?.initials : "", color: color ?? UIColor.random, circular: circular, textAttributes: textAttributes)
@@ -18,7 +18,7 @@ extension UIImageView {
}
}
- private func imageSnap(text: String?, color: UIColor, circular: Bool, textAttributes: [NSAttributedStringKey: Any]?) -> UIImage? {
+ private func imageSnap(text: String?, color: UIColor, circular: Bool, textAttributes: [NSAttributedString.Key: Any]?) -> UIImage? {
let scale = Float(UIScreen.main.scale)
var size = bounds.size
@@ -41,7 +41,7 @@ extension UIImageView {
// Text
if let text = text {
- let attributes: [NSAttributedStringKey: Any] = textAttributes ?? [.foregroundColor: UIColor.white, .font: UIFont.systemFont(ofSize: 15.0)]
+ let attributes: [NSAttributedString.Key: Any] = textAttributes ?? [.foregroundColor: UIColor.white, .font: UIFont.systemFont(ofSize: 15.0)]
let textSize = text.size(withAttributes: attributes)
let bounds = self.bounds
@@ -91,24 +91,24 @@ let kGradientBotomOffset: HSVOffset = (hue: 0.025, saturation: -0.05, brightness
extension UIImageView {
- public func setImageForName(string: String, backgroundColor: UIColor? = nil, circular: Bool, textAttributes: [NSAttributedStringKey: AnyObject]?, gradient: Bool = false) {
+ public func setImageForName(string: String, backgroundColor: UIColor? = nil, circular: Bool, textAttributes: [NSAttributedString.Key: AnyObject]?, gradient: Bool = false) {
setImageForName(string: string, backgroundColor: backgroundColor, circular: circular, textAttributes: textAttributes, gradient: gradient, gradientColors: nil)
}
- public func setImageForName(string: String, gradientColors: GradientColors? = nil, circular: Bool = true, textAttributes: [NSAttributedStringKey: AnyObject]? = nil) {
+ public func setImageForName(string: String, gradientColors: GradientColors? = nil, circular: Bool = true, textAttributes: [NSAttributedString.Key: AnyObject]? = nil) {
setImageForName(string: string, backgroundColor: nil, circular: circular, textAttributes: textAttributes, gradient: true, gradientColors: gradientColors)
}
- public func setImageForName(string: String, backgroundColor: UIColor? = nil, circular: Bool, textAttributes: [NSAttributedStringKey: AnyObject]? = nil, gradient: Bool = false, gradientColors: GradientColors? = nil) {
+ public func setImageForName(string: String, backgroundColor: UIColor? = nil, circular: Bool, textAttributes: [NSAttributedString.Key: AnyObject]? = nil, gradient: Bool = false, gradientColors: GradientColors? = nil) {
let initials: String = initialsFromString(string: string)
let color: UIColor = (backgroundColor != nil) ? backgroundColor! : randomColor(for: string)
let gradientColors = gradientColors ?? topAndBottomColors(for: color)
- let attributes: [NSAttributedStringKey: AnyObject] = (textAttributes != nil) ? textAttributes! : [
- NSAttributedStringKey.font: self.fontForFontName(name: nil),
- NSAttributedStringKey.foregroundColor: UIColor.white
+ let attributes: [NSAttributedString.Key: AnyObject] = (textAttributes != nil) ? textAttributes! : [
+ NSAttributedString.Key.font: self.fontForFontName(name: nil),
+ NSAttributedString.Key.foregroundColor: UIColor.white
]
self.image = imageSnapshot(text: initials, backgroundColor: color, circular: circular, textAttributes: attributes, gradient: gradient, gradientColors: gradientColors)
@@ -126,7 +126,7 @@ extension UIImageView {
}
- private func imageSnapshot(text imageText: String, backgroundColor: UIColor, circular: Bool, textAttributes: [NSAttributedStringKey : AnyObject], gradient: Bool, gradientColors: GradientColors) -> UIImage {
+ private func imageSnapshot(text imageText: String, backgroundColor: UIColor, circular: Bool, textAttributes: [NSAttributedString.Key : AnyObject], gradient: Bool, gradientColors: GradientColors) -> UIImage {
let scale: CGFloat = UIScreen.main.scale
diff --git a/Source/Extensions/UISegmentedControl+Extensions.swift b/Source/Extensions/UISegmentedControl+Extensions.swift
index 9775cb4e..4acf0522 100644
--- a/Source/Extensions/UISegmentedControl+Extensions.swift
+++ b/Source/Extensions/UISegmentedControl+Extensions.swift
@@ -3,15 +3,15 @@ import UIKit
public extension UISegmentedControl {
/// Font of titles
- public func title(font: UIFont) {
- let attributes: [NSAttributedStringKey: Any] = [.font: font]
- setTitleTextAttributes(attributes, for: UIControlState())
+ func title(font: UIFont) {
+ let attributes: [NSAttributedString.Key: Any] = [.font: font]
+ setTitleTextAttributes(attributes, for: UIControl.State())
//setNeedsDisplay()
//layoutIfNeeded()
}
/// Segments titles.
- public var segmentTitles: [String?] {
+ var segmentTitles: [String?] {
get {
var titles: [String?] = []
var i = 0
@@ -30,7 +30,7 @@ public extension UISegmentedControl {
}
/// Segments images.
- public var segmentImages: [UIImage?] {
+ var segmentImages: [UIImage?] {
get {
var images: [UIImage?] = []
var i = 0
diff --git a/Source/Extensions/UITextField+Extensions.swift b/Source/Extensions/UITextField+Extensions.swift
index c72de82a..84895c4f 100644
--- a/Source/Extensions/UITextField+Extensions.swift
+++ b/Source/Extensions/UITextField+Extensions.swift
@@ -12,7 +12,7 @@ extension UITextField {
func left(image: UIImage?, color: UIColor = .black) {
if let image = image {
- leftViewMode = UITextFieldViewMode.always
+ leftViewMode = UITextField.ViewMode.always
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 20, height: 20))
imageView.contentMode = .scaleAspectFit
imageView.image = image
@@ -20,14 +20,14 @@ extension UITextField {
imageView.tintColor = color
leftView = imageView
} else {
- leftViewMode = UITextFieldViewMode.never
+ leftViewMode = UITextField.ViewMode.never
leftView = nil
}
}
func right(image: UIImage?, color: UIColor = .black) {
if let image = image {
- rightViewMode = UITextFieldViewMode.always
+ rightViewMode = UITextField.ViewMode.always
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 20, height: 20))
imageView.contentMode = .scaleAspectFit
imageView.image = image
@@ -35,7 +35,7 @@ extension UITextField {
imageView.tintColor = color
rightView = imageView
} else {
- rightViewMode = UITextFieldViewMode.never
+ rightViewMode = UITextField.ViewMode.never
rightView = nil
}
}
@@ -48,12 +48,12 @@ public extension UITextField {
/// Set placeholder text color.
///
/// - Parameter color: placeholder text color.
- public func setPlaceHolderTextColor(_ color: UIColor) {
- self.attributedPlaceholder = NSAttributedString(string:self.placeholder != nil ? self.placeholder! : "", attributes:[NSAttributedStringKey.foregroundColor: color])
+ func setPlaceHolderTextColor(_ color: UIColor) {
+ self.attributedPlaceholder = NSAttributedString(string:self.placeholder != nil ? self.placeholder! : "", attributes:[NSAttributedString.Key.foregroundColor: color])
}
/// Set placeholder text and its color
func placeholder(text value: String, color: UIColor = .red) {
- self.attributedPlaceholder = NSAttributedString(string: value, attributes: [ NSAttributedStringKey.foregroundColor : color])
+ self.attributedPlaceholder = NSAttributedString(string: value, attributes: [ NSAttributedString.Key.foregroundColor : color])
}
}
diff --git a/Source/Extensions/UITextView+Extensions.swift b/Source/Extensions/UITextView+Extensions.swift
index 853b6296..8c44f189 100755
--- a/Source/Extensions/UITextView+Extensions.swift
+++ b/Source/Extensions/UITextView+Extensions.swift
@@ -4,13 +4,13 @@ import UIKit
public extension UITextView {
/// Scroll to the bottom of text view
- public func scrollToBottom() {
+ func scrollToBottom() {
let range = NSMakeRange((text as NSString).length - 1, 1)
scrollRangeToVisible(range)
}
/// Scroll to the top of text view
- public func scrollToTop() {
+ func scrollToTop() {
let range = NSMakeRange(0, 1)
scrollRangeToVisible(range)
}
diff --git a/Source/Extensions/UIView+Extensions.swift b/Source/Extensions/UIView+Extensions.swift
index 10f754c5..d6161be0 100644
--- a/Source/Extensions/UIView+Extensions.swift
+++ b/Source/Extensions/UIView+Extensions.swift
@@ -158,7 +158,7 @@ extension UIView {
public extension UIView {
/// Size of view.
- public var size: CGSize {
+ var size: CGSize {
get {
return self.frame.size
}
@@ -169,7 +169,7 @@ public extension UIView {
}
/// Width of view.
- public var width: CGFloat {
+ var width: CGFloat {
get {
return self.frame.size.width
}
@@ -179,7 +179,7 @@ public extension UIView {
}
/// Height of view.
- public var height: CGFloat {
+ var height: CGFloat {
get {
return self.frame.size.height
}
@@ -202,9 +202,9 @@ extension UIView {
public extension UIView {
- public typealias Configuration = (UIView) -> Swift.Void
+ typealias Configuration = (UIView) -> Swift.Void
- public func config(configurate: Configuration?) {
+ func config(configurate: Configuration?) {
configurate?(self)
}
@@ -213,7 +213,7 @@ public extension UIView {
/// - Parameters:
/// - corners: array of corners to change (example: [.bottomLeft, .topRight]).
/// - radius: radius for selected corners.
- public func roundCorners(_ corners: UIRectCorner, radius: CGFloat) {
+ func roundCorners(_ corners: UIRectCorner, radius: CGFloat) {
let maskPath = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
let shape = CAShapeLayer()
shape.path = maskPath.cgPath
diff --git a/Source/Pickers/Contacts/ContactsPickerViewController.swift b/Source/Pickers/Contacts/ContactsPickerViewController.swift
index af25d4db..daa4ff4d 100644
--- a/Source/Pickers/Contacts/ContactsPickerViewController.swift
+++ b/Source/Pickers/Contacts/ContactsPickerViewController.swift
@@ -169,7 +169,7 @@ final class ContactsPickerViewController: UIViewController {
let productName = Bundle.main.infoDictionary!["CFBundleName"]!
let alert = UIAlertController(style: .alert, title: "Permission denied", message: "\(productName) does not have access to contacts. Please, allow the application to access to your contacts.")
alert.addAction(title: "Settings", style: .destructive) { action in
- if let settingsURL = URL(string: UIApplicationOpenSettingsURLString) {
+ if let settingsURL = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(settingsURL)
}
}
@@ -177,6 +177,8 @@ final class ContactsPickerViewController: UIViewController {
self.alertController?.dismiss(animated: true)
}
alert.show()
+ @unknown default:
+ fatalError()
}
}
@@ -298,7 +300,7 @@ extension ContactsPickerViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {
if searchController.isActive { return 0 }
tableView.scrollToRow(at: IndexPath(row: 0, section: index), at: .top , animated: false)
- return sortedContactKeys.index(of: title)!
+ return sortedContactKeys.firstIndex(of: title)!
}
func sectionIndexTitles(for tableView: UITableView) -> [String]? {
diff --git a/Source/Pickers/Contacts/Managers/Contacts.swift b/Source/Pickers/Contacts/Managers/Contacts.swift
index 1d8e7c77..fa8026c7 100644
--- a/Source/Pickers/Contacts/Managers/Contacts.swift
+++ b/Source/Pickers/Contacts/Managers/Contacts.swift
@@ -101,7 +101,7 @@ public struct Contacts {
let contactStore: CNContactStore = CNContactStore()
let fetchRequest: CNContactFetchRequest = CNContactFetchRequest(keysToFetch: [CNContactVCardSerialization.descriptorForRequiredKeys()])
- var orderedContacts: [String: [CNContact]] = [String: [CNContact]]()
+ let orderedContacts: [String: [CNContact]] = [String: [CNContact]]()
CNContact.localizedString(forKey: CNLabelPhoneNumberiPhone)
fetchRequest.mutableObjects = false
fetchRequest.unifyResults = true
@@ -109,18 +109,21 @@ public struct Contacts {
do {
try contactStore.enumerateContacts(with: fetchRequest, usingBlock: { (contact, _) -> Void in
// Ordering contacts based on alphabets in firstname
- var key: String = "#"
// If ordering has to be happening via family name change it here.
- let firstLetter = contact.givenName[0..<1]
- if firstLetter.containsAlphabets {
- key = firstLetter.uppercased()
- }
- var contacts = [CNContact]()
- if let segregatedContact = orderedContacts[key] {
- contacts = segregatedContact
- }
- contacts.append(contact)
- orderedContacts[key] = contacts
+ fatalError("Requires fixing - No time to do this, sorry")
+
+// var key: String = "#"
+
+// let firstLetter = contact.givenName[0..<1]
+// if firstLetter.containsAlphabets {
+// key = firstLetter.uppercased()
+// }
+// var contacts = [CNContact]()
+// if let segregatedContact = orderedContacts[key] {
+// contacts = segregatedContact
+// }
+// contacts.append(contact)
+// orderedContacts[key] = contacts
})
} catch {
completionHandler(GroupedByAlphabetsFetchResults.error(error: error))
diff --git a/Source/Pickers/Contacts/Views/ContactCell.swift b/Source/Pickers/Contacts/Views/ContactCell.swift
index a4297ab0..c9bd703b 100644
--- a/Source/Pickers/Contacts/Views/ContactCell.swift
+++ b/Source/Pickers/Contacts/Views/ContactCell.swift
@@ -11,7 +11,7 @@ final class ContactTableViewCell: UITableViewCell {
// MARK: Initialize
- override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
+ override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
selectionStyle = .none
backgroundColor = nil
diff --git a/Source/Pickers/Date/DatePickerViewController.swift b/Source/Pickers/Date/DatePickerViewController.swift
index ac6bf256..91bba9b5 100644
--- a/Source/Pickers/Date/DatePickerViewController.swift
+++ b/Source/Pickers/Date/DatePickerViewController.swift
@@ -11,7 +11,7 @@ extension UIAlertController {
/// - maximumDate: maximum date of date picker
/// - action: an action for datePicker value change
- func addDatePicker(mode: UIDatePickerMode, date: Date?, minimumDate: Date? = nil, maximumDate: Date? = nil, action: DatePickerViewController.Action?) {
+ func addDatePicker(mode: UIDatePicker.Mode, date: Date?, minimumDate: Date? = nil, maximumDate: Date? = nil, action: DatePickerViewController.Action?) {
let datePicker = DatePickerViewController(mode: mode, date: date, minimumDate: minimumDate, maximumDate: maximumDate, action: action)
set(vc: datePicker, height: 217)
}
@@ -28,7 +28,7 @@ final class DatePickerViewController: UIViewController {
return $0
}(UIDatePicker())
- required init(mode: UIDatePickerMode, date: Date? = nil, minimumDate: Date? = nil, maximumDate: Date? = nil, action: Action?) {
+ required init(mode: UIDatePicker.Mode, date: Date? = nil, minimumDate: Date? = nil, maximumDate: Date? = nil, action: Action?) {
super.init(nibName: nil, bundle: nil)
datePicker.datePickerMode = mode
datePicker.date = date ?? Date()
diff --git a/Source/Pickers/Image/ImagePickerViewController.swift b/Source/Pickers/Image/ImagePickerViewController.swift
index 764e8811..3801cdd6 100644
--- a/Source/Pickers/Image/ImagePickerViewController.swift
+++ b/Source/Pickers/Image/ImagePickerViewController.swift
@@ -10,7 +10,7 @@ extension UIAlertController {
/// - images: for content to select
/// - selection: type and action for selection of image/images
- func addImagePicker(flow: UICollectionViewScrollDirection, paging: Bool, images: [UIImage], selection: ImagePickerViewController.SelectionType? = nil) {
+ func addImagePicker(flow: UICollectionView.ScrollDirection, paging: Bool, images: [UIImage], selection: ImagePickerViewController.SelectionType? = nil) {
let vc = ImagePickerViewController(flow: flow, paging: paging, images: images, selection: selection)
if UIDevice.current.userInterfaceIdiom == .pad {
@@ -48,6 +48,8 @@ final class ImagePickerViewController: UIViewController {
switch layout.scrollDirection {
case .vertical: return UIDevice.current.userInterfaceIdiom == .pad ? 3 : 2
case .horizontal: return 1
+ @unknown default:
+ fatalError()
}
}
@@ -57,6 +59,8 @@ final class ImagePickerViewController: UIViewController {
return CGSize(width: view.bounds.width / columns, height: view.bounds.width / columns)
case .horizontal:
return CGSize(width: view.bounds.width, height: view.bounds.height / columns)
+ @unknown default:
+ fatalError()
}
}
@@ -68,7 +72,7 @@ final class ImagePickerViewController: UIViewController {
$0.register(ItemWithImage.self, forCellWithReuseIdentifier: ItemWithImage.identifier)
$0.showsVerticalScrollIndicator = false
$0.showsHorizontalScrollIndicator = false
- $0.decelerationRate = UIScrollViewDecelerationRateFast
+ $0.decelerationRate = UIScrollView.DecelerationRate.fast
$0.contentInsetAdjustmentBehavior = .never
$0.bounces = false
$0.backgroundColor = .clear
@@ -90,7 +94,7 @@ final class ImagePickerViewController: UIViewController {
// MARK: Initialize
- required init(flow: UICollectionViewScrollDirection, paging: Bool, images: [UIImage], selection: SelectionType?) {
+ required init(flow: UICollectionView.ScrollDirection, paging: Bool, images: [UIImage], selection: SelectionType?) {
super.init(nibName: nil, bundle: nil)
self.images = images
self.selection = selection
diff --git a/Source/Pickers/Locale/LocalePickerViewController.swift b/Source/Pickers/Locale/LocalePickerViewController.swift
index a0091190..aac64fa9 100644
--- a/Source/Pickers/Locale/LocalePickerViewController.swift
+++ b/Source/Pickers/Locale/LocalePickerViewController.swift
@@ -84,7 +84,7 @@ final class LocalePickerViewController: UIViewController {
fileprivate lazy var indicatorView: UIActivityIndicatorView = {
$0.color = .lightGray
return $0
- }(UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge))
+ }(UIActivityIndicatorView(style: .whiteLarge))
// MARK: Initialize
@@ -297,7 +297,7 @@ extension LocalePickerViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {
if searchController.isActive { return 0 }
tableView.scrollToRow(at: IndexPath(row: 0, section: index), at: .top , animated: false)
- return sortedInfoKeys.index(of: title)!
+ return sortedInfoKeys.firstIndex(of: title)!
}
func sectionIndexTitles(for tableView: UITableView) -> [String]? {
diff --git a/Source/Pickers/Locale/Views/CountryCell.swift b/Source/Pickers/Locale/Views/CountryCell.swift
index dc04c673..4556f368 100644
--- a/Source/Pickers/Locale/Views/CountryCell.swift
+++ b/Source/Pickers/Locale/Views/CountryCell.swift
@@ -9,7 +9,7 @@ final class CountryTableViewCell: UITableViewCell {
// MARK: Initialize
- override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
+ override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .default, reuseIdentifier: reuseIdentifier)
selectionStyle = .none
backgroundColor = nil
diff --git a/Source/Pickers/Locale/Views/CurrencyCell.swift b/Source/Pickers/Locale/Views/CurrencyCell.swift
index b0ad0336..c377261a 100644
--- a/Source/Pickers/Locale/Views/CurrencyCell.swift
+++ b/Source/Pickers/Locale/Views/CurrencyCell.swift
@@ -4,7 +4,7 @@ final class CurrencyTableViewCell: UITableViewCell {
static let identifier = String(describing: CurrencyTableViewCell.self)
- override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
+ override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
selectionStyle = .none
backgroundColor = nil
diff --git a/Source/Pickers/Locale/Views/PhoneCodeCell.swift b/Source/Pickers/Locale/Views/PhoneCodeCell.swift
index d2abcec1..1fd4bd28 100644
--- a/Source/Pickers/Locale/Views/PhoneCodeCell.swift
+++ b/Source/Pickers/Locale/Views/PhoneCodeCell.swift
@@ -4,7 +4,7 @@ final class PhoneCodeTableViewCell: UITableViewCell {
static let identifier = String(describing: PhoneCodeTableViewCell.self)
- override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
+ override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
selectionStyle = .none
backgroundColor = nil
diff --git a/Source/Pickers/Location/LocationPickerViewController.swift b/Source/Pickers/Location/LocationPickerViewController.swift
index 512ac5a4..3f01bf06 100755
--- a/Source/Pickers/Location/LocationPickerViewController.swift
+++ b/Source/Pickers/Location/LocationPickerViewController.swift
@@ -90,7 +90,7 @@ final class LocationPickerViewController: UIViewController {
$0.backgroundColor = UIColor.white.withAlphaComponent(0.8)
$0.maskToBounds = true
$0.cornerRadius = 22
- $0.setImage(#imageLiteral(resourceName: "geolocation"), for: UIControlState())
+ $0.setImage(#imageLiteral(resourceName: "geolocation"), for: UIControl.State())
$0.addTarget(self, action: #selector(LocationPickerViewController.currentLocationPressed),
for: .touchUpInside)
return $0
@@ -129,11 +129,11 @@ final class LocationPickerViewController: UIViewController {
let _ = searchController.view
}
- open override func loadView() {
+ public override func loadView() {
view = mapView
}
- open override func viewDidLoad() {
+ public override func viewDidLoad() {
super.viewDidLoad()
mapView.addSubview(scaleView)
@@ -167,7 +167,7 @@ final class LocationPickerViewController: UIViewController {
var presentedInitialLocation = false
- override open func viewWillLayoutSubviews() {
+ override public func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
searchView.frame = CGRect(x: 8, y: 8, width: view.width - 16, height: 57)
//searchController.searchBar.sizeToFit()
@@ -176,7 +176,7 @@ final class LocationPickerViewController: UIViewController {
}
- override open func viewDidLayoutSubviews() {
+ override public func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
preferredContentSize.height = UIScreen.main.bounds.height
@@ -237,7 +237,7 @@ final class LocationPickerViewController: UIViewController {
}
func showCoordinates(_ coordinate: CLLocationCoordinate2D, animated: Bool = true) {
- let region = MKCoordinateRegionMakeWithDistance(coordinate, resultRegionDistance, resultRegionDistance)
+ let region = MKCoordinateRegion(center: coordinate, latitudinalMeters: resultRegionDistance, longitudinalMeters: resultRegionDistance)
mapView.setRegion(region, animated: animated)
}
@@ -314,7 +314,7 @@ extension LocationPickerViewController: UISearchResultsUpdating {
let term = userInfo[LocationPickerViewController.SearchTermKey] as? String
else { return }
- let request = MKLocalSearchRequest()
+ let request = MKLocalSearch.Request()
request.naturalLanguageQuery = term
if let location = locationManager.location, useCurrentLocationAsHint {
@@ -329,7 +329,7 @@ extension LocationPickerViewController: UISearchResultsUpdating {
}
}
- func showItemsForSearchResult(_ searchResult: MKLocalSearchResponse?) {
+ func showItemsForSearchResult(_ searchResult: MKLocalSearch.Response?) {
results.locations = searchResult?.mapItems.map { Location(name: $0.name, placemark: $0.placemark) } ?? []
results.isShowingHistory = false
results.tableView.reloadData()
@@ -382,13 +382,13 @@ extension LocationPickerViewController: MKMapViewDelegate {
func selectLocationButton() -> UIButton {
let button = UIButton(frame: CGRect(x: 0, y: 0, width: 70, height: 30))
- button.setTitle(selectButtonTitle, for: UIControlState())
+ button.setTitle(selectButtonTitle, for: UIControl.State())
if let titleLabel = button.titleLabel {
let width = titleLabel.textRect(forBounds: CGRect(x: 0, y: 0, width: Int.max, height: 30), limitedToNumberOfLines: 1).width
button.frame.size = CGSize(width: width + 10, height: 30.0)
}
button.backgroundColor = UIColor(hex: 0x007AFF)
- button.setTitleColor(.white, for: UIControlState())
+ button.setTitleColor(.white, for: UIControl.State())
button.borderWidth = 2
button.borderColor = UIColor(hex: 0x007AFF)
button.cornerRadius = 5
diff --git a/Source/Pickers/Location/Managers/SearchHistoryManager.swift b/Source/Pickers/Location/Managers/SearchHistoryManager.swift
index 4853926e..b71e3fed 100755
--- a/Source/Pickers/Location/Managers/SearchHistoryManager.swift
+++ b/Source/Pickers/Location/Managers/SearchHistoryManager.swift
@@ -9,14 +9,14 @@ struct SearchHistoryManager {
func history() -> [Location] {
let history = defaults.object(forKey: HistoryKey) as? [NSDictionary] ?? []
- return history.flatMap(Location.fromDefaultsDic)
+ return history.compactMap(Location.fromDefaultsDic)
}
func addToHistory(_ location: Location) {
guard let dic = location.toDefaultsDic() else { return }
var history = defaults.object(forKey: HistoryKey) as? [NSDictionary] ?? []
- let historyNames = history.flatMap { $0[LocationDicKeys.name] as? String }
+ let historyNames = history.compactMap { $0[LocationDicKeys.name] as? String }
let alreadyInHistory = location.name.flatMap(historyNames.contains) ?? false
if !alreadyInHistory {
history.insert(dic, at: 0)
diff --git a/Source/Pickers/Location/Models/Address.swift b/Source/Pickers/Location/Models/Address.swift
index 869dabe9..4cdd60dc 100644
--- a/Source/Pickers/Location/Models/Address.swift
+++ b/Source/Pickers/Location/Models/Address.swift
@@ -41,14 +41,14 @@ struct Address {
}
var line: String? {
- return [line1, line2].flatMap{$0}.joined(separator: ", ")
+ return [line1, line2].compactMap{$0}.joined(separator: ", ")
}
var line1: String? {
- return [[building, street].flatMap{$0}.joined(separator: " "), apt].flatMap{$0}.joined(separator: ", ")
+ return [[building, street].compactMap{$0}.joined(separator: " "), apt].compactMap{$0}.joined(separator: ", ")
}
var line2: String? {
- return [[city, zip].flatMap{$0}.joined(separator: " "), country].flatMap{$0}.joined(separator: ", ")
+ return [[city, zip].compactMap{$0}.joined(separator: " "), country].compactMap{$0}.joined(separator: ", ")
}
}
diff --git a/Source/Pickers/PhotoLibrary/PhotoLibraryPickerViewController.swift b/Source/Pickers/PhotoLibrary/PhotoLibraryPickerViewController.swift
index 05bc9eb6..5bf546ed 100644
--- a/Source/Pickers/PhotoLibrary/PhotoLibraryPickerViewController.swift
+++ b/Source/Pickers/PhotoLibrary/PhotoLibraryPickerViewController.swift
@@ -12,7 +12,7 @@ extension UIAlertController {
/// - images: for content to select
/// - selection: type and action for selection of image/images
- func addPhotoLibraryPicker(flow: UICollectionViewScrollDirection, paging: Bool, selection: PhotoLibraryPickerViewController.Selection) {
+ func addPhotoLibraryPicker(flow: UICollectionView.ScrollDirection, paging: Bool, selection: PhotoLibraryPickerViewController.Selection) {
let selection: PhotoLibraryPickerViewController.Selection = selection
var asset: PHAsset?
var assets: [PHAsset] = []
@@ -76,6 +76,8 @@ final class PhotoLibraryPickerViewController: UIViewController {
switch layout.scrollDirection {
case .vertical: return UIDevice.current.userInterfaceIdiom == .pad ? 3 : 2
case .horizontal: return 1
+ @unknown default:
+ fatalError()
}
}
@@ -85,6 +87,8 @@ final class PhotoLibraryPickerViewController: UIViewController {
return CGSize(width: view.bounds.width / columns, height: view.bounds.width / columns)
case .horizontal:
return CGSize(width: view.bounds.width, height: view.bounds.height / columns)
+ @unknown default:
+ fatalError()
}
}
@@ -96,7 +100,7 @@ final class PhotoLibraryPickerViewController: UIViewController {
$0.register(ItemWithImage.self, forCellWithReuseIdentifier: String(describing: ItemWithImage.self))
$0.showsVerticalScrollIndicator = false
$0.showsHorizontalScrollIndicator = false
- $0.decelerationRate = UIScrollViewDecelerationRateFast
+ $0.decelerationRate = UIScrollView.DecelerationRate.fast
$0.contentInsetAdjustmentBehavior = .always
$0.bounces = true
$0.backgroundColor = .clear
@@ -118,7 +122,7 @@ final class PhotoLibraryPickerViewController: UIViewController {
// MARK: Initialize
- required public init(flow: UICollectionViewScrollDirection, paging: Bool, selection: Selection) {
+ required public init(flow: UICollectionView.ScrollDirection, paging: Bool, selection: Selection) {
super.init(nibName: nil, bundle: nil)
self.selection = selection
@@ -180,7 +184,7 @@ final class PhotoLibraryPickerViewController: UIViewController {
let productName = Bundle.main.infoDictionary!["CFBundleName"]!
let alert = UIAlertController(style: .alert, title: "Permission denied", message: "\(productName) does not have access to contacts. Please, allow the application to access to your photo library.")
alert.addAction(title: "Settings", style: .destructive) { action in
- if let settingsURL = URL(string: UIApplicationOpenSettingsURLString) {
+ if let settingsURL = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(settingsURL)
}
}
@@ -188,6 +192,8 @@ final class PhotoLibraryPickerViewController: UIViewController {
self.alertController?.dismiss(animated: true)
}
alert.show()
+ @unknown default:
+ fatalError()
}
}
diff --git a/Source/Pickers/Telegram/TelegramPickerViewController.swift b/Source/Pickers/Telegram/TelegramPickerViewController.swift
index e568a651..e728b33b 100644
--- a/Source/Pickers/Telegram/TelegramPickerViewController.swift
+++ b/Source/Pickers/Telegram/TelegramPickerViewController.swift
@@ -102,7 +102,7 @@ final class TelegramPickerViewController: UIViewController {
$0.allowsMultipleSelection = true
$0.showsVerticalScrollIndicator = false
$0.showsHorizontalScrollIndicator = false
- $0.decelerationRate = UIScrollViewDecelerationRateFast
+ $0.decelerationRate = UIScrollView.DecelerationRate.fast
$0.contentInsetAdjustmentBehavior = .never
$0.contentInset = UI.insets
$0.backgroundColor = .clear
@@ -212,14 +212,17 @@ final class TelegramPickerViewController: UIViewController {
let productName = Bundle.main.infoDictionary!["CFBundleName"]!
let alert = UIAlertController(style: .alert, title: "Permission denied", message: "\(productName) does not have access to contacts. Please, allow the application to access to your photo library.")
alert.addAction(title: "Settings", style: .destructive) { action in
- if let settingsURL = URL(string: UIApplicationOpenSettingsURLString) {
+ if let settingsURL = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(settingsURL)
}
}
- alert.addAction(title: "OK", style: .cancel) { [unowned self] action in
+ alert.addAction(title: "OK", style: .cancel) { [weak self] action in
+ guard let self = self else { return }
self.alertController?.dismiss(animated: true)
}
alert.show()
+ @unknown default:
+ fatalError()
}
}
diff --git a/Source/Pickers/Telegram/Views/LikeButtonCell.swift b/Source/Pickers/Telegram/Views/LikeButtonCell.swift
index 3b3786f8..847e73dd 100644
--- a/Source/Pickers/Telegram/Views/LikeButtonCell.swift
+++ b/Source/Pickers/Telegram/Views/LikeButtonCell.swift
@@ -9,7 +9,7 @@ final class LikeButtonCell: UITableViewCell {
// MARK: Initialize
- override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
+ override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .default, reuseIdentifier: reuseIdentifier)
selectionStyle = .none
backgroundColor = nil
diff --git a/Source/Viewers/Models/AttributedTextBlock.swift b/Source/Viewers/Models/AttributedTextBlock.swift
index e6c3c71c..113549e9 100644
--- a/Source/Viewers/Models/AttributedTextBlock.swift
+++ b/Source/Viewers/Models/AttributedTextBlock.swift
@@ -11,16 +11,16 @@ public enum AttributedTextBlock {
let attributedString: NSMutableAttributedString
switch self {
case .header1(let value):
- let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.boldSystemFont(ofSize: 20), .foregroundColor: UIColor.black]
+ let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.boldSystemFont(ofSize: 20), .foregroundColor: UIColor.black]
attributedString = NSMutableAttributedString(string: value, attributes: attributes)
case .header2(let value):
- let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.boldSystemFont(ofSize: 18), .foregroundColor: UIColor.black]
+ let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.boldSystemFont(ofSize: 18), .foregroundColor: UIColor.black]
attributedString = NSMutableAttributedString(string: value, attributes: attributes)
case .normal(let value):
- let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 15), .foregroundColor: UIColor.black]
+ let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 15), .foregroundColor: UIColor.black]
attributedString = NSMutableAttributedString(string: value, attributes: attributes)
case .list(let value):
- let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 15), .foregroundColor: UIColor.black]
+ let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 15), .foregroundColor: UIColor.black]
attributedString = NSMutableAttributedString(string: "∙ " + value, attributes: attributes)
}
let paragraphStyle = NSMutableParagraphStyle()
diff --git a/Source/Viewers/TextViewController.swift b/Source/Viewers/TextViewController.swift
index 4e0d45a3..97cf2204 100644
--- a/Source/Viewers/TextViewController.swift
+++ b/Source/Viewers/TextViewController.swift
@@ -46,7 +46,7 @@ final class TextViewerViewController: UIViewController {
case .attributedText(let text):
textView.attributedText = text.map { $0.text }.joined(separator: "\n")
}
- textView.textContainerInset = UIEdgeInsetsMake(UI.hInset, UI.vInset, UI.hInset, UI.vInset)
+ textView.textContainerInset = UIEdgeInsets(top: UI.hInset, left: UI.vInset, bottom: UI.hInset, right: UI.vInset)
//preferredContentSize.height = self.textView.contentSize.height
}
diff --git a/Source/Views/GradientSlider.swift b/Source/Views/GradientSlider.swift
index 96925845..34a2bcd7 100755
--- a/Source/Views/GradientSlider.swift
+++ b/Source/Views/GradientSlider.swift
@@ -276,11 +276,11 @@ import UIKit
//MARK: - Layout
override open var intrinsicContentSize: CGSize {
- return CGSize(width: UIViewNoIntrinsicMetric, height: thumbSize)
+ return CGSize(width: UIView.noIntrinsicMetric, height: thumbSize)
}
override open var alignmentRectInsets: UIEdgeInsets {
- return UIEdgeInsetsMake(4.0, 2.0, 4.0, 2.0)
+ return UIEdgeInsets(top: 4.0, left: 2.0, bottom: 4.0, right: 2.0)
}
override open func layoutSublayers(of layer: CALayer) {
@@ -358,7 +358,7 @@ import UIKit
set(value: newValue, animated: false)
}
actionBlock(self,_value)
- sendActions(for: [UIControlEvents.valueChanged, UIControlEvents.touchUpInside])
+ sendActions(for: [UIControl.Event.valueChanged, UIControl.Event.touchUpInside])
}
diff --git a/Source/Views/Label.swift b/Source/Views/Label.swift
index c7e9f003..af429f3a 100644
--- a/Source/Views/Label.swift
+++ b/Source/Views/Label.swift
@@ -8,9 +8,9 @@ open class Label: UILabel {
open var insets: UIEdgeInsets = .zero
- override open func drawText(in rect: CGRect) {
- super.drawText(in: UIEdgeInsetsInsetRect(rect, insets))
- }
+// override open func drawText(in rect: CGRect) {
+// super.drawText(in: UIEdgeInsetsInsetRect(rect, insets))
+// }
// Override -intrinsicContentSize: for Auto layout code
override open var intrinsicContentSize: CGSize {