Category "swift"

How do I properly test a var that changes through a publisher in my viewModel in XCTestCase

Im trying to test a simple publisher within the Combine framework and SwiftUI. My test tests a published bool named isValid in my view model. My view model al

Passing an ObservableObject model through another ObObject?

I feel like I can sort of understand why what I'm doing isn't working but I'm still trying to wrap my head around Combine and SwiftUI so any help here would be

CollectionView Cell inside UITableView is not scrolling horizontally for Voice Over accessibility

In my app, I have a screen where I need to support voice over accessibility. The screen has a TableView and inside that a collectionView. When voice over is ON

Unwanted "smoothing" in AVDepthData on iPhone 13 (not evident in iPhone 12)

We are writing an app which analyzes a real world 3D data by using the TrueDepth camera on the front of an iPhone, and an AVCaptureSession configured to produce

Picker's configuration is not a valid configuration, Swift

I am working on new image picker API provided by Apple in WWDC2020 named as PHPicker. I am getting this error when I select the image form the picker second tim

Animate a UILabel and UIButton within a single UIView.transition block?

I need to animate the change of the value of a UILabel and a UIButton's image property. I currently use two UIView.transition blocks which seem to work fine, bu

How to save JPEG/RAW image data to camera roll in iOS 11, can't access processed image data

I'm attempting to write a photoapp that can take both RAW and JPEG images and save them to the camera roll. The functions jpegPhotoDataRepresentation and dngPho

Is it correct to expect internal updates of a SwiftUI DynamicProperty property wrapper to trigger a view update?

I'm attempting to create a custom property wrapper supported by SwiftUI, meaning that changes to the corresponding properties values would cause an update to th

How can I detect orthogonal scroll events when using `UICollectionViewCompositionalLayout`?

In the video Advances in Collection View Layout - WWDC 2019, Apple introduces a new 'orthogonal scrolling behavior' feature. I have a view controller almost ide

What are the delegate methods for ReplayKit's initial alert choices?

When the the user first decides to use ReplayKit there is an alert that appears. It gives 3 choices: -Record Screen and Microphone -Record Screen Only -Don&rsqu

Incorrect Video Time using mpeg4AppleHLS swift

I am creating MPEG-2 video files using mpeg4applehls profile type in avassetwriter, the videos duration or start time are wrong. I create 5-second video segment

Creating a limited count array of custom type

I am creating array of Promises of type [MSGraphScheduleInformation?]. I want to limit the array count to 4, but the repeating param in the API is throwing erro

SwiftUI picker .onChanged only firing on 2+ selection changes

I have a picker that will change an attribute of an object that is bound to the view. When the picker is changed I want to update the bound object so the change

Kotlin: Equivalent of property wrappers from Swift

What is the equivalent property wrappers for Kotlin: @propertyWrapper struct Foo { var wrappedValue: String { get { return "Test

How can I detect a right-click in SwiftUI?

I'm writing a simple Mines app to help me get to know SwiftUI. As such, I want primary click (usually LMB) to "dig" (reveal whether there's a mine there), and s

SwiftUI: How to only run code when the user stops typing in a TextField?

so I'm trying to make a search bar that doesn't run the code that displays the results until the user stops typing for 2 seconds (AKA it should reset a sort of

SwiftUI DatePicker Binding optional Date, valid nil

I'm experimenting code from https://alanquatermain.me/programming/swiftui/2019-11-15-CoreData-and-bindings/ my goal is to have DatePicker bind to Binding<

How do I set the minimum window size with swiftUI, and how do I make the window use the specified size and position when launching?

I am making a macOS app with swiftUI. I want to set the minimum size of the window to 800, 500. Also there is this thing that if I close the window, and reopen,

How to open your app's settings (inside the Settings app) with Swift (iOS 11)?

I would like to open my app's settings page inside the Settings app with Swift 4 in iOS 11. Just like the picture shows: The following codes doesn't work, it

How do I make an entity a physics entity in RealityKit?

I am not able to figure out how to make the "ball" entity a physics entity/body and apply a force to it. // I'm using UIKit for the user interface and RealityK