Category "swift"

SwiftUI on macOS - handle single-click and double-click at the same time

Consider this view in SwiftUI: struct MyView: View { var body: some View { Rectangle() .fill(Color.blue) .frame(width: 200,

Can I track more than 4 images at a time with ARKit?

Out of the box it's pretty clear ARKit doesn't allow for the tracking of more than 4 images at once. (You can "track" more markers than that but only 4 will fun

ARKit: How to add button to ARView in storyboard?

I am brand new to ARKit (and a novice in swift) but I am trying to create a basic AR app. I am following this tutorial in which a simple scene is created essent

I can't make extension convenience init for UIImage

I want to create UIImage(urlString: String?). There is no error when I run this code but it is not working. extension UIImage { convenience init?(urlString:

@MainActor is not safely when it used with propertyWrapper?

Combined use @mainActor and propertyWrapper is not safe? The code will execute directly in the background thread. It is a bug? Here is the demo: struct DetailVi

Get Image from CALayer or NSView (swift 3)

I was looking for a way to render a CALayer or NSView and get NSImage back. I have a custom class, which is a subclass of NSView. At the beginning I simply make

UIStackview align left

I'm trying to align the items in UIStackview horizontally to the left. Is there anyway to do this programmatically? I tried to do this via storyboard but was n

Swift Package Manager (SPM) and Cocoapod Dependency Conflict

Overview I have two dependencies, one available as a Swift Package, and the other only available as a Cocoapod. The problem is that each has a dependency on a t

How to initialize multiple variables of some type in one line

I want to achieve something like var a, b, c: MyType = MyType() but this line doesn't compile because compiler treats the type annotation MyType is only for

Mic input through headphones and output to iPhone speakers

Is there any way yet of being able to use wired headphones' mic as input and iPhone speakers as output using the high level AVFoundation framework: AVAudioSessi

Detect button click in WKWebview

In my IOS Application I've created a WKWebview of a website that I'm not owning myself. So inside my: func webView(_ webView: WKWebView, didFinish navigation:

How to assign default modifiers to a SwiftUI view?

I'm trying to make reusable custom views that themselves can be customized later. Ideally I'd be able to define default modifiers like Color, Font, etc that the

Swift ios check if remote push notifications are enabled in ios9 and ios10

How can I check if the user has enabled remote notifications on ios 9 or ios 10? If the user has not allowed or clicked No I want to toggle a message asking if

How to give DatePicker a minute interval in SwiftUI

does anyone know how to give the minutes DatePicker an interval? I am trying to only display multiples of 15 (0, 15, 30, 45). Is this only yet possible by inter

How to consecutively present two alert views using SwiftUI

I want to immediately present the second alert view after click the dismiss button of the first alert view. Button(action: { self.alertIsVisible = true })

How can I conform a Swift actor to a protocol while preserving isolation?

Let's say we have the following goals: We want to use actors. We want to use dependency injection and resolve actors through DI. We want to hide our actors behi

Swift function returning two different types

I need a function that can return either a String or an Int depending on the parameters entered eg: func getValue (type: String) -> (String || Int) { //thi

How to trigger Xcode's 'Update to Latest Package Versions' from command line?

Goal: I want to programmatically update the versions of Swift Packages consumed by a sample project. Problem: Xcode > 11 offers a menu option: File &

Method 'application:openURL:options:' is not called

I'm trying to open my app from a web page using custom schemes. The app is opened but the following method is not called: func application(_ app: UIApplication

Compiler error: Invalid library file - CoreLocation

I have one of my application, that is created in Xcode 8. I have used CoreLocation and MapKit in that app. I have update app with latest iOS till now. and it w