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, Swift, Objective-C and iOS Development

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, 3 years28th 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 Read more…

By malhal, 5 years6th December 2020 ago
CoreData

Dynamically filtering @FetchRequest with SwiftUI

Update 30/6/2022: I realised we shouldn’t be initing NSPredicate objects inside body so need a new approach. I was reading Paul Hudson’s article Dynamically filtering @FetchRequest with SwiftUI and thought I would share an improvement for declaring the singers @FetchRequest Read more…

By malhal, 5 years3rd December 2020 ago
SwiftUI

SwiftUI: AppStorage with Dynamic Key

If we want to use @AppStorage but with a dynamic key passed to the View we can do this: DynamicKeyApp.swift ContentView.swift

By malhal, 5 years ago
SwiftUI

SwiftUI: AppStorage with a Custom UserDefaults Suite

Here is one way to implement @AppStorage using a custom UserDefaults suite by way of the defaultAppStorage View modifier and a class extension. GroupDefaultsTestApp.swift ContentView.swift

By malhal, 5 years ago
MapKit

MKMapSnapshotter initWithOptions nullability

MKMapSnapshotter has the following constructor (within NS_ASSUME_NONNULL_BEGIN): – (instancetype)initWithOptions:(MKMapSnapshotOptions *)options NS_DESIGNATED_INITIALIZER; Which means an options param must be supplied. However the documentation contradicts this, stating “If you specify nil for this property, the snapshotter uses a set of default options Read more…

By malhal, 7 years26th May 2018 ago
CoreData

The Reason NSFetchedResultsChangeUpdate Is so Buggy

Always wondered why NSFetchedResultsChangeUpdate is so buggy? The reason is Apple don’t actually use it in their own apps. Instead, what they do is have a UITableViewCell subclass with a custom property setter for the object where they add KVO Read more…

By malhal, 8 years13th October 2017 ago
CoreData

New Way to Override NSManagedObject Properties

There is a new, yet not very well-known way to override NSManagedObject properties without needing to manually call KVO methods willChangeValueForKey etc. This is achieved using dynamic accessors prefixed with managedObjectOriginal as follows: Department.h @interface Department : NSManagedObject @property (nullable, nonatomic, Read more…

By malhal, 8 years28th September 2017 ago
Objective-C

Common Init for a UIViewController Subclass

When creating a UIViewController subclass, e.g. in a framework, which you require to support being created from both storyboards and code, it is useful to implement initialisation which works for both. That can be achieved with a common init routine Read more…

By malhal, 8 years ago
Mac

How to change the screenshot save folder on your Mac

By default, screenshots save to the Desktop which isn’t ideal. With this terminal command you can change the folder, e.g. to the Pictures folder: defaults write com.apple.screencapture location ~/Pictures To remove the setting and go back to the default do: Read more…

By malhal, 8 years19th August 2017 ago

Posts pagination

Previous 1 … 3 4 5 6 Next
Recent Posts
  • Converting from @StateObject to .task
  • @Observable and didSet
  • Dynamically filtering a SwiftData query
  • Interesting glitch with Measurement in SwiftUI
  • How to use withObservationTracking to monitor an @Observable
Recent Comments
  • SwiftUI 2: the way to open view in new window on Open window / scene in SwiftUI 2.0 on macOS
  • 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
  • February 2025
  • November 2024
  • October 2024
  • July 2024
  • May 2024
  • April 2024
  • March 2024
  • January 2024
  • December 2023
  • October 2023
  • 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
  • AppIntents
  • CloudKit
  • Concurrency
  • CoreData
  • CoreLocation
  • Mac
  • MapKit
  • NSOperation
  • Objective-C
  • Swift
  • SwiftData
  • 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