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
| extension UIEdgeInsets { | |
| init(inset: CGFloat) { | |
| self.top = inset | |
| self.bottom = inset | |
| self.left = inset | |
| self.right = inset | |
| } | |
| } |
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
| enum StatusCode: Int { | |
| // Informational | |
| case Continue = 100 | |
| case SwitchingProtocols = 101 | |
| case Processing = 102 | |
| // Success | |
| case OK = 200 | |
| case Created = 201 | |
| case Accepted = 202 |
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
| extension String { | |
| subscript (i: Int) -> Character { | |
| return self[self.startIndex.advancedBy(i)] | |
| } | |
| subscript (i: Int) -> String { | |
| return String(self[i] as Character) | |
| } |
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
| extension CGRect { | |
| var center: CGPoint { | |
| return CGPoint(x: midX, y: midY) | |
| } | |
| } |
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
| public extension Sequence { | |
| func categorise<U : Hashable>(_ key: (Iterator.Element) -> U) -> [U:Int] { | |
| var dict: [U:Int] = [:] | |
| self.forEach { el in | |
| let key = key(el) | |
| dict[key] = (dict[key] ?? 0) + 1 | |
| } | |
| return dict |
OlderNewer