Categories
iOS Development

@ScaledMetric on iOS 13

During WWDC we saw many improvements to SwiftUI. One that stood out at as particularly useful for making accessible apps was @ScaledMetric. This allows you to easily scale numeric values depending on the user’s dynamic type settings. This is fantastic for accessibility, however will only be available with iOS 14. Why wait? I’ve implemented a […]

Categories
iOS Development

Working with Arrays in SwiftUI

One of the most common things you’ll find yourself doing when building UI is dealing with arrays of data. When all you want to do is read from an array this is fairly straightforward. Things get more complicated when you want to know an item’s offset, index, or to gain mutable access via bindings. Here […]

Categories
iOS Development

Quick tip: Avoid crash when using ForEach & Bindings in SwiftUI

If you’ve played around with ForEach and .onDelete in SwiftUI you might have encountered a crash due to ‘Index out of range‘ when you delete elements that are referenced with a binding (eg. a Toggle within your ForEach closure) This occurs due to a race condition of sorts… SwiftUI is trying to read from the […]