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
@interface NSObject (KVO) | |
- (void)safelyRemoveObserver:(nonnull NSObject *)observer forKeyPath:(nonnull NSString *)keyPath; | |
@end |
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
// | |
// UIFont+MonospacedDigitsFont.swift | |
// | |
// Created by Samuel Mellert on 29/12/15. | |
// | |
import UIKit | |
extension UIFont { | |
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
// | |
// UIFont+SizeAndWeight.swift | |
// | |
// Created by Samuel Mellert on 08/01/16. | |
// | |
import UIKit | |
public enum FontWeight { | |
case Normal |
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
// Swift 2 code | |
func randomString(length: Int) -> String { | |
let charactersString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" | |
let charactersArray = Array(arrayLiteral: charactersString) | |
var string = "" | |
for _ in 0..<length { | |
string += charactersArray[Int(arc4random()) % charactersArray.count] | |
} |
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 UIFont { | |
static func monospacedDigitsSystemFontOfSize(fontSize: CGFloat, weight: CGFloat) -> UIFont { | |
let originalFontDescriptor = UIFont.systemFontOfSize(fontSize, weight: weight).fontDescriptor() | |
let fontDescriptorFeatureSettings = [ | |
[ | |
UIFontFeatureTypeIdentifierKey: kNumberSpacingType, | |
UIFontFeatureSelectorIdentifierKey: kMonospacedNumbersSelector |