In response to https://stackoverflow.com/a/77724607/1271826, this illustrates:
- How one would use legacy Alamofire API with completion handlers;
LegacyViewController
callingLegacyNetworkManager
andLegacyDatabaseManager
with GCD; and - How one might adopt Swift concurrency (async-await) with Alamofire to enjoy cancelable API calls;
SwiftConcurrencyViewController
callingNetworkManager
andDatabaseManager
.
This is a trivial example, fetching an array of Post
objects from https://jsonplaceholder.typicode.com/posts. But hopefully it illustrates the difference between legacy GCD API and contemporary Swift concurrency.
Built in Xcode 15.1 and Swift 5.9.2.
28 December 2023
Copyright © 2023 Robert M. Ryan. All Rights Reserved.
See License.