Category "swift"

SwiftUI MVVM Coordinator/Router/NavigationLink

I am having problems to translate UIKit architecture patterns to SwiftUI. My current pattern is mostly MVVM with Coordinators/Routers. The MVVM part seems quite

Swift Package Manager could not be resolved all libraries, project

This error always happens whenever I add a new Package via Swift Package Manager in Xcode: Cannot fetch library I've already configured my GitHub Auth Token

Manually set light/dark mode in SwiftUI and save users choice

I found a solution to manually set light/dark mode in a swiftui app in another thread found here https://stackoverflow.com/a/58476468/11698443 it mostly works,

How to enable pasting with keyboard shortcut into SwiftUI macOS agent application

I'm creating an app with Swift 5 and SwiftUI. The application runs as a status bar app (LSUIElement is true). I've created a simple preferences window with Swif

How to multiply two arrays element-wise

I need to multiply an array by another array element-wise, just like the Hadamard product of vectors in math. For example: A = [1,2,3,4] B = [2,3,4,5] C = A*B

TableView scrolling to top after applying UITableViewDiffableDataSource snapshot

I'm doing pagination using UITableViewDataSourcePrefetching. The values will be taken from the Realm local storage. I will get an array of objects. These values

ARKit/RealityKit – People Occlusion config not working

For some reason I can't get people occlusion to work, even though I looked at someone's question on Stackoverflow. Here is my code: //Load ARView let arView =

iOS ShareContext tapping on Suggestion Intent property of extensionContext is nil

I have a ShareExtension in my iOS app. I am trying to use Suggestions. I can successfully 'donate' the intent using the following code from the apple develope

How to work with bindings when using a view model vs using @Binding in the view itself?

@State and @Binding work so well in SwiftUI, as long as you put all the view's data inside itself, like this: struct ColorView: View { @Binding public var

Getting pixel format from CGImage

I understand bitmap layout and pixel format subject pretty well, but getting an issue when working with png / jpeg images loaded through NSImage – I can't

How to animate transition between views in SwiftUI?

I have the following view. import SwiftUI struct AppView: View { @EnvironmentObject var appStore: AppStore var body: some View { ZStack {

SwiftUI Pass Value from Geometry Reader to Function

I have a view which uses Geometry Reader to calculate how large the image area should be: GeometryReader { metrics in ZStack{ self.image

How do I make a hexagon with 6 triangular SCNNodes?

I'm trying to make a hexagon grid with triangles without altering any pivot points, but I can't seem to position the triangles correctly to make single hexagon.

How can I perform an Array Slice in Swift?

var mentions = ["@alex", "@jason", "@jessica", "@john"] I want to limit my array to 3 items, so I want to splice it: var slice = [String]() if mentions.count

ScrollView not covering entire screen in XCode

I'm running into an issue that has me rather puzzled. I have a UIView in Xcode with a ScrollView inside of it. I also have a UIView inside the ScrollView that I

How to get All Extensions for UTType Image, Audio, and Video

Is there a way to get All of the different UTType extension types as Strings? I need them specifically for images, audio, and video. I followed this answer, but

How to make Scroller background transparent in NSScrollView?

I've used Storyboard to set up the NSScrollView and I cannot find any option where I can disable the scroller's background. Any ideas on how to make this happen

SceneKit – Why does adding spot light blacken the floor?

Screenshot #1 shows a simple SceneKit scene with only an ambient light (explicitly added, not the default one). Screenshot #2 shows what happens after adding a

Swift UI: Center Text into Circle

I try to put a circle-shaped frame around a text view, but I just can't get it properly aligned and I can't see where the problem is. As you can see in the pict

SwiftUI HStack with equal Height

I want the Text("111") to have the equal height of the VStack containing 2222... and 333.... struct Test7: View { var body: some View { HStack (alignment: