Malcolm Hall

  • About
  • Research
  • Consultancy
  • Products
    • AppRecorder
    • Apps Using Location
    • Clipboard Monitor
    • Common Rocks Reference
    • Core Location Info
    • Friendify
    • Grape Stomper
    • HomeMenu
    • iBeacon Scanner
    • Insomnia
    • Navigate from Maps
    • Nickname
    • Plate Smasher
    • Plugged In
    • Readster
    • Resize Image
    • Read★
    • ScreenshotMenu
    • Sleep Display
    • SleepFX
    • Stealth Cam
    • TV Tube Sleep
    • UDID Calculator
    • WiFi Booster
    • WiFi Passwords

SwiftUI

SwiftUI

Make a Simple Circular Button in SwiftUI

I came across this interesting Stack Overflow question How can I make a simple circular button in SwiftUI in macOS? It’s interesting because all of the proposed solutions required hard-coding a frame size. I decided to experiment with how to make a circle that dynamically resizes to the size of Read more…

By malhal, 4 months1st June 2023 ago
SwiftUI

Learn SwiftUI’s View struct: value semantics, diffing and dependency tracking

Learning SwiftUI can be tricky because it has a very different design to previous UI frameworks. Many make the mistake of trying to apply old design patterns which are not really compatible because of SwiftUI’s use of value semantics and its diffing algorithm – most developers from UIKit, Java or Read more…

By malhal, 6 months23rd March 2023 ago
SwiftUI

NavigationSplitView with List selection of different types

I came across an interesting Stack Overflow question about how to support List selection of different types when using NavigationSplitView when in regular width, e.g. on iPad landscape. This problem doesn’t arise with NavigationStackView because multiple ForEach can simply iterate an array of each value and then there is a Read more…

By malhal, 9 months12th January 2023 ago
SwiftUI

Multiple sheets in SwiftUI using subviews

If you need to show multiple sheets in SwiftUI it is best to use the framework features to your advantage. Rather than try to abstract the problem into a generic coordinator object, which you then have to unbundle again to customise each circumstance, you can simply create multiple small subview Read more…

By malhal, 10 months29th November 2022 ago
SwiftUI

Nested Property Wrappers in Swift

I designed a better way to nest property wrappers than other examples I’ve seen in this article and this Stack Overflow question. The sample below is a redesigned version of the code in the question, which I also posted as an answer. Rather than use multiple property wrappers on the Read more…

By malhal, 11 months18th November 2022 ago
SwiftUI

UITextView in a UIViewRepresentable

I’ve seen a lot of code shared online getting the Coordinator wrong so thought I’d share an example of how I believe the Coordinator should be done. makeView returning context.coordinator.textView is taken from Fruta’s PaymentButton.swift but the ideas of the lazy var and textDidChange closure are my own. This means Read more…

By malhal, 11 months17th November 2022 ago
MapKit

UIViewRepresentable with Coordinator Example

There are not many examples of correctly using a Coordinator with UIViewRepresentable so thought I would share one here. You’ll see many examples including some from Apple that return Coordinator(self) which is completely wrong because the UIViewRepresentable is a struct value type which is recreated on every state change so Read more…

By malhal, 11 months16th November 2022 ago
SwiftUI

SwiftUI List EditActions

It’s hard to find this feature in the documentation so thought I’d share an example here.

By malhal, 11 months14th November 2022 ago
SwiftUI

How to get @Environment or @EnvironmentObject inside ObservableObject

Saw this interesting question on Stackoverflow and thought I would answer it. The trick is to use `DynamicProperty as an intermediary as follows:

By malhal, 1 year28th June 2022 ago
SwiftUI

Open window / scene in SwiftUI 2.0 on macOS

Update June 2022: windowing APIs have now been added so the code below might not be the best way to implement it. Here is how to open a new window or re-activate an existing one in SwiftUI on macOS. In your ContentView create a button and open a URL for Read more…

By malhal, 3 years6th December 2020 ago

Posts navigation

1 2 Next
Recent Posts
  • Make a Simple Circular Button in SwiftUI
  • How to download Apple event videos in 4K with Dolby Atmos
  • Async/await command line tool in Xcode 14.3
  • Learn SwiftUI’s View struct: value semantics, diffing and dependency tracking
  • @MainActor does not always mean main thread
Recent Comments
  • Why Does URL Scheme/onOpenURL In SwiftUI Always Open A New Window? - Programming Questions And Solutions Blog on Open window / scene in SwiftUI 2.0 on macOS
  • Ken Carroll on Enabling iOS 9.3 SDK in Xcode 8 for iOS 10
  • Mr WordPress on Welcome to my Developer Blog
Archives
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • January 2023
  • November 2022
  • June 2022
  • December 2020
  • May 2018
  • October 2017
  • September 2017
  • August 2017
  • January 2017
  • July 2016
  • May 2016
Categories
  • CloudKit
  • Concurrency
  • CoreData
  • Mac
  • MapKit
  • NSOperation
  • Objective-C
  • Swift
  • SwiftUI
  • UIKit
  • Uncategorised
  • Xcode
Meta
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
  • About
  • AppRecorder
  • Apps Using Location
  • Clipboard Monitor
  • Common Rocks Reference
  • Consultancy
  • Core Location Info
  • Friendify
  • Grape Stomper
  • HomeMenu
  • iBeacon Scanner
  • Insomnia and Insomnia Pro for iPhone
  • Navigate from Maps
  • Nickname
  • Plate Smasher
  • Plugged In
  • Products
  • Projects
  • Read★
  • Readster
  • Research
  • Resize Image
  • Sample Page
  • ScreenshotMenu
  • Sleep Display
  • SleepFX
  • Stealth Cam
  • TV Tube Sleep
  • UDID Calculator
  • WiFi Booster
  • WiFi Passwords
Hestia | Developed by ThemeIsle
 

Loading Comments...
 

You must be logged in to post a comment.