Category "swift"

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

Convert Integer to Roman Numeral String in Swift

I am looking to take an Integer in Swift and convert it to a Roman Numeral String. Any ideas?

Convert Integer to Roman Numeral String in Swift

I am looking to take an Integer in Swift and convert it to a Roman Numeral String. Any ideas?

Compute Diffie-Hellman key pair and shared secret in iOS with Swift

I need on iOS with Swift to: Generate a Diffie–Hellman key pair with a pre-agreed modulus P and a base G Compute a shared secret with a local private key,

'hitTest()' was Depecrated in iOS 14.0

I'm new to this and currently building an AR-related application, on the old version I stated this let results = self.hitTest(screenPosition, types: [.featurePo

NavigationLink inside LazyVGrid cycles all entries on back, SwiftUI

I have an image grid. Each image on tap should push a view on the NavigationView with the image details. The navigation link works as intended, but when I press

SwiftUI Modal Inherits SearchBar during Sheet Presentation

Consider the following example with a list and a button wrapped in a HStack that opens up a sheet: struct ContentView: View { @State var text: String = ""

Is there a way to preserve capitalisation of original picked file while using UIDocumentPickerViewController?

The iOS 14 SwiftUI app I am developing has two ways of importing the audio files it plays: users can open a UIDocumentPickerViewController and select an audio f

Pull to refresh in UICollectionView in ViewController

I used the following code at a UICollectionViewController override func viewDidLoad() { self.collectionView!.alwaysBounceVertical = true l

static let sharedInstance not accessible from Objective-C code

Problem: The declared static let sharedInstance is not accessible from Objective-C code when building the main app target. Code: @objc public protocol Manag

Print Struct name in swift

It is possible to know the name of a struct in swift ? I know this is possible for class: Example class Example { var variable1 = "one" var variable2 =

Fixing the size of a custom font in SwiftUI iOS 13+ when ignoring Dynamic Type

In an app I'm developing (SwiftUI for iOS13 and above), I have imported a custom font, and I load the font using the following method": func getDigitalXFontOfS