-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1cf0d35
commit 025d1d4
Showing
3 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// API.swift | ||
// UI Testing | ||
// | ||
// Created by Graeme Read on 25/11/2016. | ||
// Copyright © 2016 Graeme Read. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
struct API { | ||
|
||
// MARK: - Structs | ||
struct Constants { | ||
static let delay = 4 | ||
} | ||
|
||
|
||
// MARK: - Instance methods | ||
func retrieveData(completion: @escaping (String) -> Void) { | ||
delay(Constants.delay) { | ||
completion("Hello World") | ||
} | ||
} | ||
|
||
|
||
// MARK: - Private methods | ||
private func delay(_ delay: Int, block: @escaping () -> Void) { | ||
let delay = DispatchTime.now() + Double(Int64(UInt64(delay) * NSEC_PER_SEC)) / Double(NSEC_PER_SEC) | ||
DispatchQueue.main.asyncAfter(deadline: delay, execute: block) | ||
} | ||
|
||
} |
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