Created
September 8, 2022 08:38
-
-
Save barisuyar/b6fb6fcf3fec5844ecae78000c80c197 to your computer and use it in GitHub Desktop.
Call mock service
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
final class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
URLProtocol.registerClass(MockURLProtocol.self) | |
guard let url = URL(string: "www.google.com.tr") else { return } | |
let request = URLRequest(url: url) | |
URLSession.shared.dataTask(with: request) { data, response, error in | |
guard let data = data, | |
let person = try? JSONDecoder().decode(Person.self, from: data) else { return } | |
print(person.name) | |
print(person.age) | |
}.resume() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment