import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
print(mult(no1: 2, no2: 20))
print(mult(no1: 3, no2: 15))
print(mult(no1: 4, no2: 30))
}
func mult(no1: Int, no2: Int) -> Int {
return no1 * no2
}
}
tmutil thinlocalsnapshots / 20000000000 4
import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate { // Здесь протокол WKUIDelegate
@IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
self.webView?.uiDelegate = self // Делегат
let hey = "https://example.com"
webView.load(URLRequest(url: URL(string: hey)!))
}
// И этот метод
func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
if navigationAction.targetFrame == nil {
webView.load(navigationAction.request)
}
return nil
}
}
import UIKit
import WebKit
class ViewController: UIViewController {
@IBOutlet weak var webView: WKWebView! // Аутлет на ваше WKWebView
override func viewDidLoad() {
super.viewDidLoad()
show()
}
// Метод для вывода страницы из файла page.html, который находится в любом месте вашего проекта.
private func show() {
let path = Bundle.main.path(forResource: "page", ofType: "html")!
print(path)
do {
let contents = try String(contentsOfFile: path, encoding: .utf8)
webView.loadHTMLString(contents as String, baseURL: nil)
webView.sizeToFit()
} catch let error {
print("Error: ", error.localizedDescription)
}
}
}