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 XCTest | |
/// An expectation that is fulfilled when a Key Value Observing (KVO) condition | |
/// is met. It's variant of `XCTKVOExpectation` with support for native Swift | |
/// key paths. | |
final class KVOExpectation: XCTestExpectation { | |
private var kvoToken: NSKeyValueObservation? | |
/// Creates an expectation that is fulfilled when a KVO change causes the | |
/// specified key path of the observed object to have an expected value. |
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 UIColor { | |
convenience init(hexNumber: UInt32) { | |
let red = CGFloat(hexNumber >> 16 & 0xFF) / 255 | |
let green = CGFloat(hexNumber >> 8 & 0xFF) / 255 | |
let blue = CGFloat(hexNumber & 0xFF) / 255 | |
self.init(red: red, green: green, blue: blue, alpha: 1) | |
} | |
convenience init?(hexString: String) { | |
guard let number = UInt32(hexString, radix: 16) else { |
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 SheetAction = () -> Void | |
class ActionSheet: UIActionSheet { | |
private var actions = [SheetAction]() | |
convenience init() { | |
self.init(frame: CGRectZero) | |
delegate = self |
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 Foundation | |
func sha1(data: NSData) -> String { | |
let length = Int(CC_SHA1_DIGEST_LENGTH) | |
var digest = [UInt8](count: length, repeatedValue: 0) | |
CC_SHA1(data.bytes, CC_LONG(data.length), &digest) | |
return digest.map { String(format: "%02x", $0) }.reduce("", +) | |
} | |
func sha1(string: String) -> 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
import UIKit | |
private let scale = UIScreen.mainScreen().scale | |
class PixelConstraint: NSLayoutConstraint { | |
override var constant: CGFloat { | |
get { return super.constant / scale } | |
set(value) { super.constant = value } | |
} | |
} |
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
var result: Unmanaged<AnyObject>? | |
SecItemCopyMatching(query, &result) | |
// Doesn't work on 32-bit platforms (probably due to compiler bug) | |
return result?.takeUnretainedValue() as? NSData |
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 | |
class SegmentedControl: UIControl { | |
private let action = Selector("selectSegment:") | |
@IBOutlet | |
private var segments: [UIButton] = [] { | |
didSet { | |
segments.sortInPlace { $0.tag < $1.tag } | |
subscribe(segments) |
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
typealias EventHandler = (AnyObject) -> Void | |
class Event { | |
var handlers: [EventHandler] = [] | |
func subscribe(handler: EventHandler) { | |
handlers.append(handler) | |
} | |
dynamic func invoke(sender: AnyObject) { |
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
Вы ранее привлекались за хранение данных в глобальных переменных? | |
Вы когда-нибудь делали .Net за деньги? | |
Сформулируйте зависимость времени исправления критического бага от seniority присутствующего менеджера | |
В своём резюме вы указали знание php. вам не стыдно? | |
Перед вами кисть, холст и мольберт. напишите компилятор |
NewerOlder