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
import XCUI | |
class SmartXCUICoordinate | |
{ | |
let element: XCUIElement | |
let normalizedOffset: CGVector | |
init(element: XCUIElement, normalizedOffset offset: CGVector) { | |
self.element = element | |
self.normalizedOffset = offset |
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
// WARNING: No thought involved while writing this, introduce some prior to production use. I warned you. | |
var timer: dispatch_source_t! | |
func startWatchdog() { | |
let q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0) | |
guard let timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, q) else { return } | |
self.timer = timer | |
dispatch_source_set_timer(timer, dispatch_time(DISPATCH_TIME_NOW, 0), NSEC_PER_SEC / 10, (UInt64(1) * NSEC_PER_SEC) / 10) | |
dispatch_source_set_event_handler(timer) { |
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
NSNumber *a = @5; | |
NSNumber *b = @5; | |
NSLog(@"%d", a == b); // 1 | |
NSNumber *c = @(NSIntegerMax); | |
NSNumber *d = @(NSIntegerMax); | |
NSLog(@"%d", c == d); // 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
enum E { | |
case A | |
case B | |
} | |
let dict: [String: E?] = [ | |
"a": nil, | |
"c": .A | |
] |
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
import Foundation | |
let locale = NSLocale(localeIdentifier: "ru_RU") | |
let dateFormatter = NSDateFormatter() | |
dateFormatter.timeStyle = .ShortStyle | |
dateFormatter.dateStyle = .MediumStyle | |
dateFormatter.locale = locale | |
dateFormatter.doesRelativeDateFormatting = true |
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
// http://stackoverflow.com/questions/29365781/weird-behavious-using-optionals-inside-closure | |
struct GameSettings {} | |
protocol Delegate { | |
func didFinishSettings(settings: GameSettings, controller: Controller) | |
} | |
class Controller { | |