Category: SwiftUI

  • How to simplify persistent data using @AppStorage

    In SwiftUI, the @AppStorage property wrapper that assists how we interact with UserDefaults, streamlining the process of persisting data. By simplifying data persistence, @AppStorage makes reading from and writing to UserDefaults more straightforward and integrated within the SwiftUI framework. Let us take the following example where we are trying to store tap count in User…

  • How to detect availability of internet connection in Swift

    In today’s world, mobile apps are a big part of our lives. Many of these apps need an internet connection to work properly. This is why it’s so important for app developers to make sure users have a smooth experience, whether they are connected to the internet or not. On iOS devices, developers can use…

  • Understanding .onAppear and .onDisappear in SwiftUI

    SwiftUI simplifies the way developers think about the lifecycle of views with its declarative syntax. Unlike UIKit, which requires you to manage the lifecycle through methods like viewDidLoad, viewWillAppear, and viewWillDisappear, SwiftUI provides .onAppear and .onDisappear modifiers for executing code when a view appears or disappears. This tutorial demonstrates how to use these modifiers in…

  • Button in Swift UI – Code Snippet

    A button in SwiftUI is a fundamental interactive component that allows users to trigger actions. SwiftUI Button Basics The two main elements for creating a button are Let us see this with an example of having a button in Expense Split app to add expenses The above code snippets defines the trigger action which is…