Tag: SwiftUI

  • Opaque Types in Swift: Hiding Details, Not Power

    Opaque Types in Swift: Hiding Details, Not Power

    Have you ever wanted to return some kind of value from a function but didn’t want to expose exactly what type it is? Like telling the compiler, I’ll tell you it conforms to a protocol, but you don’t need to know the concrete type. Just trust me, it’ll work. Well, that’s what opaque types are…

  • Clean, Reusable Swift Code Using DRY Principle

    Clean, Reusable Swift Code Using DRY Principle

    Hey Switfers! 👋Today we will explore the DRY principle to make our Swift code clean and reusable. So have you ever written a function, copy-pasted it somewhere else, tweaked a line or two, and thought, this looks kinda familiar? If so, you have probably broken a rule we all learn (and forget) early on The…

  • Stepper in SwiftUI

    Stepper in SwiftUI

    Today, we’re going to dive deep into the Stepper control – a versatile and user-friendly way to increment or decrement values in your SwiftUI apps. We’ll explore various ways to implement and customize Steppers, from basic usage to more advanced techniques. What is a Stepper? A Stepper in SwiftUI is a control that lets users…

  • Fall Detection API in Swift for WatchOS

    Fall Detection API in Swift for WatchOS

    I was recently implementing the Fall Detection API in Swift/SwiftUI for watchOS, and I had a lot of trouble getting it working. The documentation was very sparse, and I ended up wasting a lot of hours trying to figure out how to use the API. I was finally able to get it working after about 95% of the way…

  • List in SwiftUI

    List in SwiftUI

    To create a list in SwiftUI, you can use the List view. Here is an example of how you could create a list of names using the List view: In this example, the List view is initialized with the names array and a closure that specifies what each item in the list should look like.…