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
func validateArray<T>(_ array: [T?]) -> [T] { | |
var validElements: [T] = [] | |
for case let element? in array { | |
validElements.append(element) | |
} | |
return validElements | |
} |
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 | |
// NOTE: percentageThreshold is shared across all instances of SwipeControl | |
private var percentageThreshold: Int = 75 | |
private enum Direction { | |
case left, right, none | |
} |
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 | |
/** | |
In the xib IB, make the used custom view class (subclass of NibView) | |
the File’s Owner and connect the view outlet to the xib view. | |
*/ | |
class NibView: UIView { | |
@IBOutlet weak private var view: UIView! | |
var nibName: String { |
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
/// Used to identify the intended format of a string when using the `attributedTextFromArray:` func of a UILabel extension. | |
enum FontType { | |
case system, bold, italic, underlined | |
} | |
extension UILabel { | |
/** | |
Assigns attributed text to the label by iterating through an array of strings with associated FontTypes. | |
Example use: |
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 UIView { | |
/// Checks the constraints of this view's superview, as well as all of it's subviews, for the constraint with the identifier passed. | |
func constraint(withIdentifier identifier: String) -> NSLayoutConstraint? { | |
if let constraint = superview?.constraintFiltered(identifier) { | |
return constraint | |
} else if let constraint = constraintFiltered(identifier) { | |
return constraint |
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 | |
typealias ConnectionDrawing = Void -> Void | |
class LineGraphView: UIView { | |
var data = [Double]() | |
var offset: CGFloat = 0.0 | |
var shownRange = 0 ..< 0 | |
var maximumValueShown: Double = 0.0 |
NewerOlder