Fixed some swiftlint warnings
This commit is contained in:
parent
5b6250722f
commit
1885a24296
|
@ -43,7 +43,7 @@ extension Array {
|
|||
}
|
||||
|
||||
/// EZSE: Iterates on each element of the array with its index. (Index, Element)
|
||||
public func forEachEnumerated(_ body: @escaping (_ offset: Int, _ element: Element) -> ()) {
|
||||
public func forEachEnumerated(_ body: @escaping (_ offset: Int, _ element: Element) -> Void) {
|
||||
self.enumerated().forEach(body)
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ extension Array where Element: Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
//MARK: - Deprecated 1.8
|
||||
// MARK: - Deprecated 1.8
|
||||
|
||||
extension Array {
|
||||
|
||||
|
@ -241,13 +241,13 @@ extension Array where Element: Equatable {
|
|||
|
||||
}
|
||||
|
||||
//MARK: - Deprecated 1.7
|
||||
// MARK: - Deprecated 1.7
|
||||
|
||||
extension Array {
|
||||
|
||||
/// EZSE: Iterates on each element of the array with its index. (Index, Element)
|
||||
@available(*, deprecated: 1.7, renamed: "forEachEnumerated(_:)")
|
||||
public func forEach(_ call: @escaping (Int, Element) -> ()) {
|
||||
public func forEach(_ call: @escaping (Int, Element) -> Void) {
|
||||
forEachEnumerated(call)
|
||||
}
|
||||
|
||||
|
@ -287,13 +287,13 @@ extension Array where Element: Equatable {
|
|||
|
||||
}
|
||||
|
||||
//MARK: - Deprecated 1.6
|
||||
// MARK: - Deprecated 1.6
|
||||
|
||||
extension Array {
|
||||
|
||||
/// EZSE: Iterates on each element of the array.
|
||||
@available(*, deprecated: 1.6, renamed: "forEach(_:)")
|
||||
public func each(_ call: (Element) -> ()) {
|
||||
public func each(_ call: (Element) -> Void) {
|
||||
forEach(call)
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ extension Array {
|
|||
|
||||
/// EZSE: Iterates on each element of the array with its index. (Index, Element)
|
||||
@available(*, deprecated: 1.6, renamed: "forEachEnumerated(_:)")
|
||||
public func each(_ call: @escaping (Int, Element) -> ()) {
|
||||
public func each(_ call: @escaping (Int, Element) -> Void) {
|
||||
forEachEnumerated(call)
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ import UIKit
|
|||
|
||||
///Make sure you use `[weak self] (NSURLRequest) in` if you are using the keyword `self` inside the closure or there might be a memory leak
|
||||
open class BlockWebView: UIWebView, UIWebViewDelegate {
|
||||
open var didStartLoad: ((URLRequest) -> ())?
|
||||
open var didFinishLoad: ((URLRequest) -> ())?
|
||||
open var didFailLoad: ((URLRequest, Error) -> ())?
|
||||
open var didStartLoad: ((URLRequest) -> Void)?
|
||||
open var didFinishLoad: ((URLRequest) -> Void)?
|
||||
open var didFailLoad: ((URLRequest, Error) -> Void)?
|
||||
|
||||
open var shouldStartLoadingRequest: ((URLRequest) -> (Bool))?
|
||||
|
||||
|
|
|
@ -73,10 +73,10 @@ extension CGFloat {
|
|||
let twoPi = CGFloat(.pi * 2.0)
|
||||
var angle = (second - first).truncatingRemainder(dividingBy: twoPi)
|
||||
if angle >= .pi {
|
||||
angle = angle - twoPi
|
||||
angle -= twoPi
|
||||
}
|
||||
if angle <= -.pi {
|
||||
angle = angle + twoPi
|
||||
angle += twoPi
|
||||
}
|
||||
return angle
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ extension CGRect {
|
|||
}
|
||||
|
||||
/// EZSE : Surface Area represented by a CGRectangle
|
||||
public var area : CGFloat {
|
||||
public var area: CGFloat {
|
||||
return self.h * self.w
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,19 +18,15 @@ extension Character {
|
|||
|
||||
/// EZSE: Convert the character to lowercase
|
||||
public var lowercased: Character {
|
||||
get {
|
||||
let s = String(self).lowercased()
|
||||
return s[s.startIndex]
|
||||
}
|
||||
}
|
||||
|
||||
/// EZSE: Convert the character to uppercase
|
||||
public var uppercased: Character {
|
||||
get {
|
||||
let s = String(self).uppercased()
|
||||
return s[s.startIndex]
|
||||
}
|
||||
}
|
||||
|
||||
/// EZSE : Checks if character is emoji
|
||||
var isEmoji: Bool {
|
||||
|
|
|
@ -200,7 +200,7 @@ extension Date {
|
|||
}
|
||||
|
||||
/// EZSE : Gets the nano second from the date
|
||||
public var nanosecond : Int {
|
||||
public var nanosecond: Int {
|
||||
return Calendar.current.component(.nanosecond, from: self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ extension Dictionary where Value: Equatable {
|
|||
}
|
||||
|
||||
/// EZSE: Combines the first dictionary with the second and returns single dictionary
|
||||
public func += <KeyType, ValueType> (left: inout Dictionary<KeyType, ValueType>, right: Dictionary<KeyType, ValueType>) {
|
||||
public func += <KeyType, ValueType> (left: inout [KeyType: ValueType], right: [KeyType: ValueType]) {
|
||||
for (k, v) in right {
|
||||
left.updateValue(v, forKey: k)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ extension Double {
|
|||
public var toInt: Int { return Int(self) }
|
||||
}
|
||||
|
||||
//MARK: - Deprecated 1.8
|
||||
// MARK: - Deprecated 1.8
|
||||
|
||||
extension Double {
|
||||
|
||||
|
@ -45,8 +45,8 @@ extension Double {
|
|||
}
|
||||
|
||||
/// EZSE: Absolute value of Double.
|
||||
public var abs : Double {
|
||||
if (self > 0) {
|
||||
public var abs: Double {
|
||||
if self > 0 {
|
||||
return self
|
||||
} else {
|
||||
return -self
|
||||
|
|
|
@ -181,7 +181,7 @@ public struct ez {
|
|||
}
|
||||
|
||||
/// EZSE: Calls action when a screen shot is taken
|
||||
public static func detectScreenShot(_ action: @escaping () -> ()) {
|
||||
public static func detectScreenShot(_ action: @escaping () -> Void) {
|
||||
let mainQueue = OperationQueue.main
|
||||
NotificationCenter.default.addObserver(forName: NSNotification.Name.UIApplicationUserDidTakeScreenshot, object: nil, queue: mainQueue) { notification in
|
||||
// executes after screenshot
|
||||
|
@ -205,30 +205,30 @@ public struct ez {
|
|||
// MARK: - Dispatch
|
||||
|
||||
/// EZSE: Runs the function after x seconds
|
||||
public static func dispatchDelay(_ second: Double, closure:@escaping ()->()) {
|
||||
public static func dispatchDelay(_ second: Double, closure:@escaping () -> Void) {
|
||||
DispatchQueue.main.asyncAfter(
|
||||
deadline: DispatchTime.now() + Double(Int64(second * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: closure)
|
||||
}
|
||||
|
||||
/// EZSE: Runs function after x seconds
|
||||
public static func runThisAfterDelay(seconds: Double, after: @escaping () -> ()) {
|
||||
public static func runThisAfterDelay(seconds: Double, after: @escaping () -> Void) {
|
||||
runThisAfterDelay(seconds: seconds, queue: DispatchQueue.main, after: after)
|
||||
}
|
||||
|
||||
//TODO: Make this easier
|
||||
/// EZSE: Runs function after x seconds with dispatch_queue, use this syntax: dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0)
|
||||
public static func runThisAfterDelay(seconds: Double, queue: DispatchQueue, after: @escaping ()->()) {
|
||||
public static func runThisAfterDelay(seconds: Double, queue: DispatchQueue, after: @escaping () -> Void) {
|
||||
let time = DispatchTime.now() + Double(Int64(seconds * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
|
||||
queue.asyncAfter(deadline: time, execute: after)
|
||||
}
|
||||
|
||||
/// EZSE: Submits a block for asynchronous execution on the main queue
|
||||
public static func runThisInMainThread(_ block: @escaping ()->()) {
|
||||
public static func runThisInMainThread(_ block: @escaping () -> Void) {
|
||||
DispatchQueue.main.async(execute: block)
|
||||
}
|
||||
|
||||
/// EZSE: Runs in Default priority queue
|
||||
public static func runThisInBackground(_ block: @escaping () -> ()) {
|
||||
public static func runThisInBackground(_ block: @escaping () -> Void) {
|
||||
DispatchQueue.global(qos: .default).async(execute: block)
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ extension UInt {
|
|||
|
||||
/// EZSE: Greatest common divisor of two integers using the Euclid's algorithm.
|
||||
/// Time complexity of this in O(log(n))
|
||||
public static func gcd(_ firstNum:UInt, _ secondNum:UInt) -> UInt {
|
||||
public static func gcd(_ firstNum: UInt, _ secondNum: UInt) -> UInt {
|
||||
let remainder = firstNum % secondNum
|
||||
if remainder != 0 {
|
||||
return gcd(secondNum, remainder)
|
||||
|
@ -69,7 +69,7 @@ extension UInt {
|
|||
}
|
||||
|
||||
/// EZSE: Least common multiple of two numbers. LCM = n * m / gcd(n, m)
|
||||
public static func lcm(_ firstNum:UInt, _ secondNum:UInt) -> UInt {
|
||||
public static func lcm(_ firstNum: UInt, _ secondNum: UInt) -> UInt {
|
||||
return firstNum * secondNum / UInt.gcd(firstNum, secondNum)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import Foundation
|
|||
|
||||
public extension NSDictionary {
|
||||
|
||||
//MARK: - Deprecated 1.8
|
||||
// MARK: - Deprecated 1.8
|
||||
|
||||
/// EZSE: Unserialize JSON string into NSDictionary
|
||||
@available(*, deprecated: 1.8)
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
// swiftlint:disable trailing_whitespace
|
||||
|
||||
#if os(OSX)
|
||||
import AppKit
|
||||
import AppKit
|
||||
#else
|
||||
import UIKit
|
||||
import UIKit
|
||||
#endif
|
||||
|
||||
extension String {
|
||||
|
@ -200,11 +200,9 @@ extension String {
|
|||
|
||||
/// EZSE: Checks if string is empty or consists only of whitespace and newline characters
|
||||
public var isBlank: Bool {
|
||||
get {
|
||||
let trimmed = trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return trimmed.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
/// EZSE: Trims white space and new line characters
|
||||
public mutating func trim() {
|
||||
|
@ -366,7 +364,7 @@ extension String {
|
|||
}
|
||||
|
||||
/// EZSE: Converts String to NSString
|
||||
public var toNSString: NSString { get { return self as NSString } }
|
||||
public var toNSString: NSString { return self as NSString }
|
||||
|
||||
#if os(iOS)
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ extension Timer {
|
|||
}
|
||||
|
||||
/// EZSE: Run function after x seconds
|
||||
public static func runThisAfterDelay(seconds: Double, after: @escaping () -> ()) {
|
||||
public static func runThisAfterDelay(seconds: Double, after: @escaping () -> Void) {
|
||||
runThisAfterDelay(seconds: seconds, queue: DispatchQueue.main, after: after)
|
||||
}
|
||||
|
||||
//TODO: Make this easier
|
||||
/// EZSwiftExtensions - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0)
|
||||
public static func runThisAfterDelay(seconds: Double, queue: DispatchQueue, after: @escaping ()->()) {
|
||||
public static func runThisAfterDelay(seconds: Double, queue: DispatchQueue, after: @escaping () -> Void) {
|
||||
let time = DispatchTime.now() + Double(Int64(seconds * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
|
||||
queue.asyncAfter(deadline: time, execute: after)
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ extension UIFont {
|
|||
return Font(.AvenirNext, type: .Regular, size: size)
|
||||
}
|
||||
|
||||
//MARK: Deprecated
|
||||
// MARK: Deprecated
|
||||
|
||||
/// EZSwiftExtensions
|
||||
@available(*, deprecated: 1.8)
|
||||
|
|
|
@ -95,7 +95,7 @@ extension UIImageView {
|
|||
}
|
||||
}
|
||||
|
||||
//MARK: Deprecated 1.8
|
||||
// MARK: Deprecated 1.8
|
||||
|
||||
/// EZSwiftExtensions
|
||||
@available(*, deprecated: 1.8, renamed: "image(url:)")
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
// Copyright (c) 2015 Goktug Yilmaz. All rights reserved.
|
||||
// swiftlint:disable trailing_whitespace
|
||||
|
||||
|
||||
import UIKit
|
||||
|
||||
extension UIViewController {
|
||||
|
@ -27,7 +26,6 @@ extension UIViewController {
|
|||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
|
||||
#if os(iOS)
|
||||
|
||||
///EZSE: Adds a NotificationCenter Observer for keyboardWillShowNotification()
|
||||
|
@ -78,7 +76,6 @@ extension UIViewController {
|
|||
self.removeNotificationObserver(NSNotification.Name.UIKeyboardDidHide.rawValue)
|
||||
}
|
||||
|
||||
|
||||
public func keyboardDidShowNotification(_ notification: Notification) {
|
||||
if let nInfo = (notification as NSNotification).userInfo, let value = nInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue {
|
||||
|
||||
|
@ -150,7 +147,6 @@ extension UIViewController {
|
|||
|
||||
///EZSE: Returns maximum y of the ViewController
|
||||
public var top: CGFloat {
|
||||
get {
|
||||
if let me = self as? UINavigationController, let visibleViewController = me.visibleViewController {
|
||||
return visibleViewController.top
|
||||
}
|
||||
|
@ -164,11 +160,9 @@ extension UIViewController {
|
|||
return view.top
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///EZSE: Returns minimum y of the ViewController
|
||||
public var bottom: CGFloat {
|
||||
get {
|
||||
if let me = self as? UINavigationController, let visibleViewController = me.visibleViewController {
|
||||
return visibleViewController.bottom
|
||||
}
|
||||
|
@ -182,11 +176,9 @@ extension UIViewController {
|
|||
return view.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///EZSE: Returns Tab Bar's height
|
||||
public var tabBarHeight: CGFloat {
|
||||
get {
|
||||
if let me = self as? UINavigationController, let visibleViewController = me.visibleViewController {
|
||||
return visibleViewController.tabBarHeight
|
||||
}
|
||||
|
@ -195,11 +187,9 @@ extension UIViewController {
|
|||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
///EZSE: Returns Navigation Bar's height
|
||||
public var navigationBarHeight: CGFloat {
|
||||
get {
|
||||
if let me = self as? UINavigationController, let visibleViewController = me.visibleViewController {
|
||||
return visibleViewController.navigationBarHeight
|
||||
}
|
||||
|
@ -208,7 +198,6 @@ extension UIViewController {
|
|||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
///EZSE: Returns Navigation Bar's color
|
||||
public var navigationBarColor: UIColor? {
|
||||
|
@ -224,17 +213,13 @@ extension UIViewController {
|
|||
|
||||
///EZSE: Returns current Navigation Bar
|
||||
public var navBar: UINavigationBar? {
|
||||
get {
|
||||
return navigationController?.navigationBar
|
||||
}
|
||||
}
|
||||
|
||||
/// EZSwiftExtensions
|
||||
public var applicationFrame: CGRect {
|
||||
get {
|
||||
return CGRect(x: view.x, y: top, width: view.w, height: bottom - top)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - VC Flow
|
||||
|
||||
|
|
|
@ -476,7 +476,7 @@ extension UIView {
|
|||
}
|
||||
|
||||
/// EZSwiftExtensions - Make sure you use "[weak self] (gesture) in" if you are using the keyword self inside the closure or there might be a memory leak
|
||||
public func addTapGesture(tapNumber: Int = 1, action: ((UITapGestureRecognizer) -> ())?) {
|
||||
public func addTapGesture(tapNumber: Int = 1, action: ((UITapGestureRecognizer) -> Void)?) {
|
||||
let tap = BlockTap(tapCount: tapNumber, fingerCount: 1, action: action)
|
||||
addGestureRecognizer(tap)
|
||||
isUserInteractionEnabled = true
|
||||
|
@ -498,7 +498,7 @@ extension UIView {
|
|||
}
|
||||
|
||||
/// EZSwiftExtensions - Make sure you use "[weak self] (gesture) in" if you are using the keyword self inside the closure or there might be a memory leak
|
||||
public func addSwipeGesture(direction: UISwipeGestureRecognizerDirection, numberOfTouches: Int = 1, action: ((UISwipeGestureRecognizer) -> ())?) {
|
||||
public func addSwipeGesture(direction: UISwipeGestureRecognizerDirection, numberOfTouches: Int = 1, action: ((UISwipeGestureRecognizer) -> Void)?) {
|
||||
let swipe = BlockSwipe(direction: direction, fingerCount: numberOfTouches, action: action)
|
||||
addGestureRecognizer(swipe)
|
||||
isUserInteractionEnabled = true
|
||||
|
@ -512,7 +512,7 @@ extension UIView {
|
|||
}
|
||||
|
||||
/// EZSwiftExtensions - Make sure you use "[weak self] (gesture) in" if you are using the keyword self inside the closure or there might be a memory leak
|
||||
public func addPanGesture(action: ((UIPanGestureRecognizer) -> ())?) {
|
||||
public func addPanGesture(action: ((UIPanGestureRecognizer) -> Void)?) {
|
||||
let pan = BlockPan(action: action)
|
||||
addGestureRecognizer(pan)
|
||||
isUserInteractionEnabled = true
|
||||
|
@ -532,7 +532,7 @@ extension UIView {
|
|||
#if os(iOS)
|
||||
|
||||
/// EZSwiftExtensions - Make sure you use "[weak self] (gesture) in" if you are using the keyword self inside the closure or there might be a memory leak
|
||||
public func addPinchGesture(action: ((UIPinchGestureRecognizer) -> ())?) {
|
||||
public func addPinchGesture(action: ((UIPinchGestureRecognizer) -> Void)?) {
|
||||
let pinch = BlockPinch(action: action)
|
||||
addGestureRecognizer(pinch)
|
||||
isUserInteractionEnabled = true
|
||||
|
@ -548,7 +548,7 @@ extension UIView {
|
|||
}
|
||||
|
||||
/// EZSwiftExtensions - Make sure you use "[weak self] (gesture) in" if you are using the keyword self inside the closure or there might be a memory leak
|
||||
public func addLongPressGesture(action: ((UILongPressGestureRecognizer) -> ())?) {
|
||||
public func addLongPressGesture(action: ((UILongPressGestureRecognizer) -> Void)?) {
|
||||
let longPress = BlockLongPress(action: action)
|
||||
addGestureRecognizer(longPress)
|
||||
isUserInteractionEnabled = true
|
||||
|
@ -597,7 +597,7 @@ extension UIView {
|
|||
}
|
||||
}
|
||||
|
||||
//MARK: Fade Extensions
|
||||
// MARK: Fade Extensions
|
||||
|
||||
private let UIViewDefaultFadeDuration: TimeInterval = 0.4
|
||||
|
||||
|
|
Loading…
Reference in New Issue