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 Sequence { | |
func grouped<T>(by criteria: (Element) -> T) -> [T: [Element]] { | |
var dict = [T: [Element]]() | |
for element in self { | |
let key = criteria(element) | |
if dict.keys.contains(key) == false { | |
dict[key] = [Element]() | |
} | |
dict[key]?.append(element) | |
} |
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 QuartzCore | |
extension CALayer { | |
@objc var borderUIColor: UIColor { | |
set { | |
self.borderColor = newValue.cgColor | |
} | |
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 UIStackView { | |
func removeAllArrangedSubviews() { | |
let removedSubviews = arrangedSubviews.reduce([]) { (allSubviews, subview) -> [UIView] in | |
self.removeArrangedSubview(subview) | |
return allSubviews + [subview] | |
} |