Apps often need to read the content of JSON files for different reasons.
You can save static JSON data inside an Xcode project to populate your app or use it in SwiftUI previews.
Apps can also save data inside the device’s documents directory.
Swift and iOS Development Best Practices
Apps often need to read the content of JSON files for different reasons.
You can save static JSON data inside an Xcode project to populate your app or use it in SwiftUI previews.
Apps can also save data inside the device’s documents directory.
JSON data is often not human-readable because web servers strip all white space to save bandwidth.
Converting JSON data into a formatted string helps build decodable Swift types and is useful for debugging, saving data to a JSON File, and writing unit tests for an app’s JSON output.
The Date
type is a Codable
type in Swift. However, dates are not straightforward to decode, like other types conforming to the Codable
protocol, because the default format used by JSONDecoder
is not standard in JSON.
Dates can be encoded using different formats in JSON data. To handle all these formats, the JSONDecoder class has a dateDecodingStrategy
property, which can be configured with several decoding strategies according to the date format you must decode.
Since the introduction of SwiftUI, the MVVM pattern has experienced a renaissance. Many developers believe this particular pattern aligns well with the SwiftUI data flow.
MVVM incorporates good ideas but also introduces problems due to varying interpretations of the pattern and its perceived rigidity.
In this article, we’ll explore how MVVM fits into SwiftUI, how to leverage its advantages, and how to navigate its challenges.
Most modern iOS apps need to run code asynchronously. Async functions can be suspended and resumed later, allowing your app to keep its UI responsive while working on long tasks, like making REST API calls. In this article, we will see how to run asynchronous functions in Swift and iOS apps using async/await. Table of … Read more
Becoming an iOS developer is a great career choice that allows you to demand a high salary and work on interesting projects at top companies.
Learning iOS development can take time, but you can speed up the process and optimize your learning following the steps I outline in this article.
You can make a REST API call in Swift in just three lines of code thanks to URLSession
and async/await.
However, implementing a networking layer in a full-fledged app presents several architectural pitfalls.
In this article we will see how REST works, how to perform API calls in a SwiftUI app, and the best way to architect the networking layer of an iOS app.