Last active
October 10, 2019 18:15
-
-
Save azamsharp/74e62b843b9e9cc3c4d9de2fe0493b7e to your computer and use it in GitHub Desktop.
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 Post { | |
let id = UUID().uuidString | |
let title: String | |
let body: String | |
} | |
class Webservice { | |
func fetchPosts(completion: @escaping ([Post]) -> Void) { | |
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { | |
// fetch from a web api and then populate the Post array | |
let posts = [ | |
Post(title: "Hello SwiftUI", body: "Learn to create your first SwiftUI App!"), | |
Post(title: "Getting started with Combine", body: "Introduce reactive programming using Combine framework") | |
] | |
completion(posts) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment