Я пытаюсь запустить этот код на детской площадке:
//: Playground - noun: a place where people can play
import UIKit
import XCTest
// Create an expectation for a background download task.
let expectation = XCTestExpectation(description: "Download apple.com home page")
// Create a URL for a web page to be downloaded.
let url = URL(string: "https://apple.com")!
// Create a background task to download the web page.
let dataTask = URLSession.shared.dataTask(with: url) { (data, _, _) in
// Make sure we downloaded some data.
XCTAssertNotNil(data, "No data was downloaded.")
// Fulfill the expectation to indicate that the background task has finished successfully.
expectation.fulfill()
}
// Start the download task.
dataTask.resume()
// Wait until the expectation is fulfilled, with a timeout of 10 seconds.
wait(for: [expectation], timeout: 10.0)
Я скопировал его из https://developer.apple.com/documentation/xctest/asynchronous_tests_and_expectations/testing_asynchronous_operations_with_expectations
Я получаю ошибку:
Playground execution failed:
error: MyPlayground2.playground:21:35: error: extra argument 'timeout' in call
wait(for: [expectation], timeout: 10.0)
^~~~
Почему я получаю эту ошибку на детской площадке?При использовании wait (for: timeout :) в обычном проекте это работает.