This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import Darwin | |
| class FrameworkViewController: UIViewController { | |
| @IBOutlet weak var vPluginContainer: UIView! | |
| var timer: Timer? | |
| typealias startFuncPrototype = @convention(c) (Double, Double) -> Void | |
| typealias tickFuncPrototype = @convention(c) (TimeInterval) -> Void |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| extension String { | |
| var trimmed: String { | |
| self.trimmingCharacters(in: .whitespacesAndNewlines) | |
| } | |
| mutating func trim() { | |
| self = self.trimmed | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| extension Int { | |
| func toDouble() -> Double { | |
| Double(self) | |
| } | |
| } | |
| extension Double { | |
| func toInt() -> Int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| extension String { | |
| func toDate(format: String) -> Date? { | |
| let df = DateFormatter() | |
| df.dateFormat = format | |
| return df.date(from: self) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| extension Int { | |
| func centsToDollars() -> Double { | |
| Double(self) / 100 | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import CoreLocation | |
| extension String { | |
| var asCoordinates: CLLocationCoordinate2D? { | |
| let components = self.components(separatedBy: ",") | |
| if components.count != 2 { return nil } | |
| let strLat = components[0].trimmed | |
| let strLng = components[1].trimmed | |
| if let dLat = Double(strLat), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| extension String { | |
| var asURL: URL? { | |
| URL(string: self) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import AudioToolbox | |
| extension UIDevice { | |
| static func vibrate() { | |
| AudioServicesPlaySystemSound(1519) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| extension String { | |
| func height(withConstrainedWidth width: CGFloat, font: UIFont) -> CGFloat { | |
| let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude) | |
| let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [.font: font], context: nil) | |
| return ceil(boundingBox.height) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| extension String { | |
| var containsOnlyDigits: Bool { | |
| let notDigits = NSCharacterSet.decimalDigits.inverted | |
| return rangeOfCharacter(from: notDigits, options: String.CompareOptions.literal, range: nil) == nil | |
| } | |
| } |