335,807 questions
0
votes
0
answers
15
views
Why does calling map() on an array yield an extraneous value in an Xcode Playground
My code:
import UIKit
let arr: [Int] = [1, 2, 3]
let result = arr.map { x in x + 2 }
result
Here is what an Xcode 16.2 Playground shows for the results:
Where does the extra 5 come from on line 4?
...
-1
votes
0
answers
14
views
WatchOS compass
I am creating a watchOS app and using a red arrow svg to track something moving around. The problem I am running into is the point part (the top edge of the svg) needs to always points outwards from ...
0
votes
0
answers
9
views
SwiftUI How do I go about getting the BackgroundColor under text / view so I can invert the foreground color
Been trying to find a solution to dynamically detect the Background Color / the color underneath the View you want to modify, since I may want to have readable text over a Image without resorting to ...
-5
votes
2
answers
54
views
Double(): why does it sometimes convert to an optional type and other times not?
I get no errors with the following function definition:
func calculate(price: String, prevBalance: Double) -> Double
{
guard let itemPrice = Double(price) else {
print("Error for ...
0
votes
0
answers
21
views
How to use SectionedFetchRequest in a view model?
I have a SwiftUI view that I want to move the fetch request in a view model.
For normal fetching I did it like this
Consider this model
class MyType {
let title: String
let category: String
...
0
votes
0
answers
8
views
UITextView in input bar does not stay attached to keyboard after dismissal
I’m building a chat feature for my iOS app with a custom input bar (UITextView and "Send" button) that stays attached to the keyboard. When the user types, the input bar behaves as expected ...
0
votes
0
answers
10
views
Crash inside of Vision framework during VNImageRequestHandler use
I've been dealing with a puzzling issue for some time now, and I’m hoping someone here might have insights or suggestions.
The Problem: We’re observing an occasional crash in our app that seems to ...
0
votes
1
answer
37
views
Xcode predictive code completion not work with Image(systemName: )
When I want to use some system image I can't just remember them all, and I was hoping that new Xcode prediction will help here. But it does not know any even popular system images. Maybe I need to ...
0
votes
2
answers
41
views
task (lowercased) vs. Task (capitalized)
What's the difference?
task {
// ... //
}
Task {
// ... //
}
I discovered it by accident.
Task is the right struct, when you want to create an asynchronous task. But writing ...
0
votes
2
answers
34
views
How to dynamically adjust the width of a TextField to its content?
I want to make a TextField in SwiftUI that adjusts its width dynamically based on the content, without adding extra spacing.
The TextField is part of an HStack with several Text views, and my goal is ...
-1
votes
1
answer
24
views
SWIFT, SQLite, Cannot convert value of type 'String' to expected argument type 'Int64', expression, ios 16+ [duplicate]
Cannot convert value of type 'String' to expected argument type 'Int64'
or
Cannot convert value of type 'Expression<String>' to expected argument type 'Expression<Int64?>'
These errors ...
0
votes
0
answers
42
views
Why does my App freeze when declaring a State var of Type Date()?
I wanted to add a functionality to my App to store different Times (hour:minute) in an array of my SwiftData Model. And then to also add and remove items from this array. I ran into two problems.
The ...
0
votes
0
answers
36
views
Issue with "OK" button not closing alert in Swift
I have an alert in Swift that is supposed to close when the "OK" button is clicked. Unfortunately, this doesn't happen. Visually, I can see in the app that the "OK" button is ...
-1
votes
0
answers
9
views
Unable to adda remote Swift package to my project in Xcode [duplicate]
I wish to add the Swift Factory package as a remote package to my project. Selecting File -> Add Package Dependencies in Xcode 16.2 displays the package selection screen. This screen cannot resolve ...
0
votes
0
answers
28
views
Problem displaying the name of my number blocking app since iOS 18.2
I am writing an application to block spam calls on my mobile and since iOS 18.2 I encounter a problem, it is that in my call log instead of the name of my application, I have something else that ...