Category "swift"

Swift: Triggering sound effects during a timer

I've created a super simple count down application. You press a button, and the count down runs. The end result calculating looks like this: 10.0 9.999 9.998 .

Lazy initialisation and retain cycle

While using lazy initialisers, is there a chance of having retain cycles? In a blog post and many other places [unowned self] is seen class Person { var

LottieAnimationView size won't change/is too small (iOS/Swift)

Whether the view I'm creating is a LOTAnimatedSwitch or View, the image of the animation always appears very small. The lottie animation doesn't take up the siz

MEMixerChannel.cpp:1577 Spatialization not supported on this platform (err=-4)

I'm playing a sound in my watch only app, but every time the sound plays the debugger shows an error: "MEMixerChannel.cpp:1577 Spatialization not supported on

MEMixerChannel.cpp:1577 Spatialization not supported on this platform (err=-4)

I'm playing a sound in my watch only app, but every time the sound plays the debugger shows an error: "MEMixerChannel.cpp:1577 Spatialization not supported on

Swift Combine HTTP request

Trying to figure out how to make quick http requests using combine. I've mostly been looking at this doc by Apple. I haven't made any progress though and it see

SwiftUI TabBar: Action for tapping TabItem of currently selected Tab to reset view

The app I am working on is based around a TabBar, and when I am on a tab I want to be able to click the tabItem again to reset the view, similar to how Twitter

How to use environment map in ARKit?

ARKit 2.0 added a new class named AREnvironmentProbeAnchor. Reading it's instructions, it seems that ARKit can automatically collect environment texture (cubema

Pass data from ViewController to Representable SwiftUI

I am doing an object detection and used UIViewControllerRepresentable to add my view controller. The thing is that I can't pass data from my ViewController to m

Adding 3D object to ARGeoAnchor

Please forgive me if this question is not that great. I've hit a bit of a road block on Apple's documentation of ARGeoAnchor. Currently ARGeoAnchor just shows a

A Swift protocol requirement that can only be satisfied by using a final class

I'm modeling a owner/ownee scheme on Swift: class Owner<T: Ownee> { // ... } protocol Ownee { var owner: Owner<Self> { get } } Then I h

SWIFT: Button Title changing back to original title unwarranted

So I have the following code which executes upon tapping one side or another of my segmented control: @IBAction func logInOrSignUpIndexChanged(_ sender: UISegme

UIBarButtonItem Initializer with Image and Title does not show Title

I am using init(title:image:primaryAction:menu:) of a UIBarButtonItem Apple Documentation on a Toolbar with the hope of showing a button with both image and tit

iOS button title color won't change

I'm creating a UIButton dynamically with the following code which creates it as per specified style. let frame = CGRect(x: 10, y: 6, width: 60, height: 30 )

iOS Document Picker crashes when picking a PDF on a real device

I try to create a Document Picker for my iOS app. Here is my code (I wrapped the UIDocumentPickerViewController in my SwiftUI View, with UIViewControllerReprese

How to compare a color in swift

I am trying to compare colors but I cannot use the isEqual method because I am trying to compare the color of the background of a UICollectionViewCell. What is

SwiftUI - How to deinit a StateObject when navigating back?

I want my @StateObject to be deinitialized as soon as possible after I navigate back, but it seems that the object is held in memory. "Deint ViewModel" is not b

How to force macOS File Provider Extension to re-enumerate items

Is there a way to force macOS File Provider Extension to re-enumerate items for given parent container? I am aware that we can signalEnumerator(for: .workingSet

Initialize a String from a range of Characters in Swift

In our code, we found a bug from not writing the alphabet correctly. Instead of "0123456789abcdefghijklmnopqrstuvwxyz", we had "0123456789abcdefghijklmnoqprstuv

SwiftUI prevent onReceive from firing on load

Is there any way to prevent onReceive from firing when the view initially loads when the variable I'm trying to receive is a @Published property of an @Environm