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
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { | |
let convertedPoint = button.convert(point, from: self) | |
return button.point(inside: convertedPoint, with: event) | |
} |
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
actor GoodActor { | |
var count: Int = 0 | |
let limit = 5 | |
func displayAndUpdate() { | |
guard count < 5 else { | |
return | |
} |
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
final class DataRacer { | |
var count: Int = 0 | |
let limit = 5 | |
func displayAndUpdate() { | |
guard count < 5 else { | |
return | |
} |
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
func fetchDataPair(from urls: (URL, URL)) async throws -> (ModelWrapper, ModelWrapper) { | |
async let resultOne = fetchData(from: urls.0) | |
async let resultTwo = fetchData(from: urls.1) | |
return try await (resultOne, resultTwo) | |
} |
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
func fetchDataPair(from urls: (URL, URL)) async throws -> (ModelWrapper, ModelWrapper) { | |
let resultOne = try await fetchData(from: urls.0) | |
let resultTwo = try await fetchData(from: urls.1) | |
return (resultOne, resultTwo) | |
} |
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
func fetchData(from url: URL) async throws -> ModelWrapper { | |
let (data, _) = try await URLSession.shared.data(from: url) | |
let model = try JSONDecoder().decode(Model.self, from: data) | |
let (imageData, _) = try await URLSession.shared.data(from: model.imageURL) | |
guard let image = UIImage(data: imageData) else { | |
throw APIErrors.imageDecodingError | |
} | |
return ModelWrapper(model: model, image: image) | |
} |
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
struct Model: Decodable { | |
let id: Int | |
let name: String | |
let imageURL: URL | |
} | |
struct ModelWrapper { | |
let model: Model | |
let image: UIImage | |
} |
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
func fetchData(from url: URL, withCompletion completion: @escaping (Result<ModelWrapper, Error>) -> Void) -> Void { | |
let firstTask = URLSession.shared.dataTask(with: url) { data, response, error in | |
if let error = error { | |
completion(.failure(error)) | |
// 😱 DID NOT RETURN! | |
} | |
guard let data = data else { |
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
final class ShowBugTestCase: BaseTestCase { | |
let showBugRobot = ShowBugRobot() | |
func testShowBugButtonsDisplaysAlert() { | |
// When | |
showBugRobot | |
.tapShowBugButton() | |
// Then |
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 XCTest | |
let app = XCUIApplication() | |
class BaseTestCase: XCTestCase { | |
override func setUpWithError() throws { | |
continueAfterFailure = false | |
app.launch() | |
} |
NewerOlder