Category "swift"

How do I refactor my code to call AppDelegate on the main thread?

I recently started migrating my project from Swift3/Xcode8 to Swift4/Xcode9. My app crashes at runtime because the main thread sanitizer allows access to UIAppl

RealityKit as a framework to build 3D nonAR apps

RealityKit has an option for .nonAR camera, but lacks fundamental options to build 3D nonAR apps, like camera control (.allowsCameraComtrol). Is it viable to us

In iOS (swift) app, registration of a second Firebase app can't receive remote notifications

I'm having two Firebase projects (on se same account, but could be two different accounts) and each project have an iOS app registered with the same bundle ID (

How to count occurrences of an element in a Swift array?

I've seen a few examples of this but all of those seem to rely on knowing which element you want to count the occurrences of. My array is generated dynamically

Xcode won't pause at this breakpoint because it has not been resolved

Shortly after updating to Xcode 13.2.1 I started seeing some weird behaviour of breakpoints. When I run an app (in a simulator) some of my breakpoints change th

Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path | Xcode 13.3

I am submitting a .xcarchive to the App Store via Xcode 13.3 but I keep on getting the following email error: ITMS-90562: Invalid Bundle - One or more dynamic l

How to adjust brightness contrast saturation in swift with a UISlider

I have been looking for the past couple of days on how to implement a filter to a UIImage by manually manipulating the brightness, contrast, highlight, shadows,

Horizontal scroll UICollectionView has additional line spacing?

I'm trying to use UICollectionView to make a table, when I set it to vertical scroll, everything is working great. But when I set it to horizontal scroll, it a

How to Remove UIMenuController Default Items In Swift

I'm trying to remove the items Look Up & Share... from the UIMenuController. How would I specifically remove the two and keep my custom one. Here is what I'

Best Way to Update/Edit an Array Element in SwiftUI

I have an array of identifiable Training elements. Each Training element only has two properties, name and isRequired. What is the most straight-forward (Swif

how to overload an assignment operator in swift

I would like to override the '=' operator for a CGFloat like the follow try : func = (inout left: CGFloat, right: Float) { left=CGFloat(right) } So I cou

WKWebView not showing Navigation Bar

I have a view in SwiftUI that shows a WKWebView which is passed to the main ContentView using the UIViewControllerRepresentable class, implemented following the

How to return data from WKWebView to JavaScript

I am developing a hybrid Android and iOS app using WebViews. However, I am struggling to return data from iOS app back to my Javascript. Below is how I setup t

Stereo ARSCNview to make VR and AR mix

I want to make a mix of virtual reality and augmented reality. The goal is I have a stereo camera (for each eyes). I tried to put two ARSCNView in a viewCotnro

The app delegate must implement the window property if it wants to use a main storyboard file swift

I have just developed an app, but when running in the simulator the debugger console says: The app delegate must implement the window property if it wants t

Check for duplicate characters in string using for-loops in swift

I did this using while loops but I'm wondering if there's a way to do this with for loops. I'm trying to write this clean so I can write it on a whiteboard for

How to detect when AVPlayer video ends playing?

I'am using AVPlayer for playing local video file (mp4) in Swift. Does anyone know how to detect when video finish with playing? Thanks

Check if key exists in dictionary of type [Type:Type?]

How can I check if a key exists in a dictionary? My dictionary is of type [Type:Type?]. I can't simply check dictionary[key] == nil, as that could result from

SwiftUI TapGesture onStart / TouchDown

I am using the TapGesture in SwiftUI for MacOS. TapGesture is only recognized on TouchInsideOut event, when releasing the press again. I want to call an action

Flutter - getApplicationDocumentsDirectory() : How to get the path in android and iOS

Directory tempDir = await getTemporaryDirectory(); String tempPath = tempDir.path; In android native code, I use getCacheDir() How do i get the getApplicatio