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
DispatchQueue.main.async { | |
// execute async on main thread | |
} |
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
class CustomThread: Thread { | |
override func main() { | |
do_something | |
} | |
} | |
let customThread = CustomThread() | |
customThread.start() |
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
let task = Process() | |
task.launchPath = "/bin/sh" //executable you want to run | |
task.arguments = arguments //here is the information you want to pass | |
task.terminationHandler = { | |
// do here something in case the process terminates | |
} | |
task.launch() |
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
func method2() { | |
statement1 { | |
callback1() | |
} | |
statement2 | |
} |
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
func method1() { | |
statement1() | |
statement2() | |
statement3() | |
statement4() | |
} |
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 paws: MonkeyPaws? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
if CommandLine.arguments.contains("--MonkeyPaws") { | |
paws = MonkeyPaws(view: window!) | |
} | |
return true | |
} |
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
func testMonkey() { | |
let application = XCUIApplication(bundleIdentifier: "de.olbrich.jan.SnapshotTesting") | |
_ = application.descendants(matching: .any).element(boundBy: 0).frame | |
let monkey = Monkey(frame: application.frame) | |
monkey.addDefaultUIAutomationActions() | |
monkey.addXCTestTapAlertAction(interval: 100, application: application) | |
monkey.monkeyAround() | |
} |
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
func getRandomCoordinate() -> XCUICoordinate { | |
let x = CGFloat(Float(arc4random()) / Float(UINT32_MAX)) | |
let y = CGFloat(Float(arc4random()) / Float(UINT32_MAX)) | |
let vector = CGVector(dx: x, dy: y) | |
let coordinate = getCoordinateForVector(vector: vector) | |
return coordinate | |
} |
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
// our algorithm has this signature | |
func isCorrectEmail(email Email) -> Bool | |
property("emails should always be correct") <- forAll { (email: Email) in | |
return isCorrectEmail(email) | |
} |
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 Email: Arbitray { | |
public static var arbitrary: Gen<Email> { | |
return Gen.compose { comp in | |
return Email(comp.generate(localEmail), comp.generate(hostname), comp.generate(tld)) | |
} | |
} | |
} |