This file contains 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
/** | |
Represents a semantic version number in the form X.Y.Z | |
Its most useful feature is that it implements `Comparable` | |
making for easy comparison checks. | |
*/ | |
struct VersionNumber { | |
let version: String | |
init(version: String) { |
This file contains 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
- (NSString *)description { | |
//We list the properties and their values using the ever convenient `dictionaryWithValuesForKeys` | |
//which will get the values of the corresponding properties | |
NSDictionary *debugProperties = [self dictionaryWithValuesForKeys:@[NSStringFromSelector(@selector(<#Insert property name#>))]]; | |
return [NSString stringWithFormat:@"<%@: %p> %@", self.class, self, debugProperties]; | |
} |
This file contains 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 delay(delay:Double, closure:()->()) { | |
dispatch_after( | |
dispatch_time( | |
DISPATCH_TIME_NOW, | |
Int64(delay * Double(NSEC_PER_SEC)) | |
), | |
dispatch_get_main_queue(), closure) | |
} |
This file contains 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
extension UITableView { | |
/** | |
Returns an index path identifying the row and section | |
of the cell containing the provided view | |
:param: cellSubview A subview of any given UITableViewCell in the table. Typically this is either a `UIButton` or `UITextField` | |
*/ | |
func indexPathForCellWithSubview(cellSubview: UIView) -> NSIndexPath? { | |
let cellFrame = convertRect(cellSubview.bounds, fromView: cellSubview) | |
let cellCenter = CGPoint(x: CGRectGetMidX(cellFrame), y: CGRectGetMidY(cellFrame)) |
This file contains 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
extension UIView { | |
func addConstaintsToPinHorizontalEdgesToSuperView(padding: CGFloat = 0) { | |
prepareForConstraints() | |
self.superview!.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-(padding)-[view]-(padding)-|", | |
options: NSLayoutFormatOptions(0), | |
metrics: ["padding":padding], | |
views: ["view":self])) | |
} | |
func addConstaintsToPinVerticalEdgesToSuperView(padding: CGFloat = 0) { |
This file contains 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
/// RepeatingTimer mimics the API of DispatchSourceTimer but in a way that prevents | |
/// crashes that occur from calling resume multiple times on a timer that is | |
/// already resumed (noted by https://github.com/SiftScience/sift-ios/issues/52 | |
class RepeatingTimer { | |
let timeInterval: TimeInterval | |
init(timeInterval: TimeInterval) { | |
self.timeInterval = timeInterval | |
} |
OlderNewer