A SwiftUI view showing buttons for taking a photo and opening photo album.
Observing a KVO compatible model in SwiftUI and MVVM
In model-view-view model (MVVM) architecture the view model observes the model and provides data for the view by transforming it when needed. When the user interacts with the view and changes the data in it then the view model's responsibility is to propagate those mutations back to the model object. Therefore, the important part in …
Continue reading "Observing a KVO compatible model in SwiftUI and MVVM"
Animating a custom wave shape in SwiftUI
Wave shape with red button on top of it
Sharing data from CoreData storage with a Widget on iOS
WWDC’20 introduced WidgetKit which is a new framework for building widgets on iOS, iPadOS, and macOS. Widgets provide a quick way for displaying content from your app either on the home screen on iOS or on the notification center on macOS. As I have an iOS app which stores data with CoreData then let’s see …
Continue reading "Sharing data from CoreData storage with a Widget on iOS"
@StateObject and MVVM in SwiftUI
A while ago I wrote about using MVVM in a SwiftUI project. During the WWDC’20 Apple announced @StateObject property wrapper which is a nice addition in the context of MVVM. @StateObject makes sure that only one instance is created per a view structure. This enables us to use @StateObject property wrappers for class type view …
Separating code with Swift packages in Xcode
Xcode 12 comes with Swift toolchain 5.3 which brings resource and localisation support to Swift packages. Nice thing is that Swift package support only depends on the toolchain's version and does not have additional OS requirements. At the same time, let's keep in mind that OS requirements come from the code we actually add to …
Continue reading "Separating code with Swift packages in Xcode"
Picker and segmented control in SwiftUI on iOS
Picker is used for presenting a selection consisting of multiple options. UISegmentedControl which is known from UIKit is just a different picker style in SwiftUI. Let's take a quick look on how to create a form with two items: picker with default style and picker with segmented style. Creating a from Form should be typically …
Continue reading "Picker and segmented control in SwiftUI on iOS"
Using SwiftUI previews for UIKit views
SwiftUI provides wrappers for UIViewController and UIView on iOS. Same wrappers are also available for AppKit views on macOS. Let's see how to use those wrappers for rendering UIKit views in SwiftUI previews and therefore benefiting from seeing changes immediately. Note that even when a project can't support SwiftUI views because of the minimum deployment …
Signal Path 2.0 for iOS and macOS is available now!
I am happy to announce that Signal Path 2.0 is available now for macOS and iOS. Signal Path uses Apple's universal purchase offering - buy it once for both platforms. Signal Path 2.0 on the App Store Past, present, and future I spent a lot of time architecting both apps in a way that they …
Continue reading "Signal Path 2.0 for iOS and macOS is available now!"
Setting an equal width to text views in SwiftUI
Let's take a look on how to set an equal width to multiple views where the width equals to the widest Text() view in SwiftUI. SwiftUI does not have an easy to use view modifier for this at the moment, therefore we'll add one ourselves. Example use case is displaying two text bubbles with width …
Continue reading "Setting an equal width to text views in SwiftUI"