3,125 questions
-3
votes
0
answers
121
views
In UIKit, is the behavior of detached Task exactly as described in this example?
I have this code:
func drawCount() {
Task {
await _drawCount()
}
}
func _drawCount() async {
let k = await Task.detached(priority: .low) {
return gfed.filter{$0.blah}....
-1
votes
2
answers
104
views
How to decode multiple date formats (ISO8601 string, Unix timestamp, null) into a single Date? using a Swift property wrapper [closed]
I have a Swift model using Codable, and my backend is inconsistent with date formats:
Sometimes a date comes as ISO8601 string ("2025-09-30T04:00:00Z")
Sometimes as a Unix timestamp (...
-3
votes
1
answer
66
views
Is this keyboard-related button on iPad some sort of standard existing system component?
We have a UX where the "paradigm" of a button is similar to this:
so I want to exactly duplicate the look.
Is this something standard available in UIKit, or is it just a UIButton that Apple ...
-5
votes
1
answer
77
views
Layout not called when constraints have been applied, particularly to labels, under a view? (Could be a bug / simulator problem.)
I had a custom UIView V which adds a stack view S with three labels L. It draws some CAShapeLayer lines.
class CustomView: UIView {
///Consumers supply some texts and other info
var input: [ ...
-1
votes
1
answer
94
views
I was disappointed to discover Comparable seems to have no .min call? Is that correct or am I missing something?
I just did this,
1, 5, 100, 2, 7 becomes 5, 100, 7
1, 2, 18, 19, 5, 4 becomes 2, 19, 5
extension Array where Element: Comparable {
///Simply return the bigger of each pair of (say) integers ...
-1
votes
2
answers
74
views
Is it possible to use UIDynamicAnimator with items in a Scroll/StackView, rather than a collection view?
Say you have a vertical collection view, you can add typical "springy" physics by incorporating UIDynamicAnimator in the UICollectionViewLayout.
Simple example below.
Now imagine just a ...
-1
votes
2
answers
65
views
How to call an optional array extension from another?
An extension ...
fileprivate extension Optional {
///Do an upsert for one item - works on all groups
mutating func upsert<T: MyProtocol>(item: T) where Wrapped == [T] {
}
}
which ...
0
votes
1
answer
64
views
When using a CAShapeLayer, is there any advantage at all to using a UIBezierPath over just constructing a cgPath?
When I have
private lazy var aLine: RepairedCAShapeLayer {
let v = RepairedCAShapeLayer()
v.contentsScale = UIScreen.main.scale
v.strokeColor = cfp.color.cgColor
v.fillColor = nil
...
0
votes
1
answer
99
views
Is it correct that copy on write is applied to (all) the "original" array if a change is made to that array while there happens to be a copy extant?
Say
struct Teste: Codable {
let a: Int
lazy var x: Int = {
print("I just changed this Teste item")
return a + 1000
}()
}
and you
var hugeData: [Teste] // 750 ...
0
votes
1
answer
80
views
Animating performBatchUpdates in UICollectionView - how to remove the fade style?
I have a typical ...
"user selects one row, all other rows go away, there is now only one row in the data source, the row's new position is (obviously) now the top and only row: row X slides up ...
0
votes
1
answer
89
views
Why async await compiles with Swift 4.2
I have an iOS project with some async await functions. I update Swift Language Version setting in Xcode Build Settings to 4.2 and the project still able to compile. How Swift 4.2 knows how to compile ...
0
votes
1
answer
68
views
Why does Core Animation have a delay compared to Core Graphics?
I am trying to implement a custom UISlider on an iOS device.
First, the ThumbSlider is positioned on both ends, and the desired behavior is as follows: When the ThumbSlider moves left or right, the ...
5
votes
0
answers
425
views
SecPKCS12Import failed on iOS 17.5, but work well on iOS 18.0
I have been using SecPKCS12Import to retrieve the kSecImportItemIdentity from a .p12 certificate.
While this method works well on iOS 18.0, it returns an error code -25293 on iOS 17.5 or lower.
I use ...
2
votes
1
answer
87
views
Can an enum be an array type?
I often have something like ..
enum DotNetType: String, CaseIterable {
case guid = "Guid"
case int = "Int32"
case float = "Single"
case dateTime = "...
0
votes
2
answers
225
views
How do you write a typed nil in Swift?
I have a situation where I have to return a typed nil.
The only way I know of to "make" a typed nil is ..
// need to return String nil
var x: String? = nil
return x
..
// need to return ...
0
votes
1
answer
45
views
how to create an audio file which processingFormat is in16 in swift?
This is my code, processingFormat is always <AVAudioFormat 0x3016b46e0: 1 ch, 16000 Hz, Float32>, how to make it to be Int16?
`let documentDirectory = FileManager.default.urls(for: ....
0
votes
2
answers
57
views
Open URL Only Works in Main Storyboard View Controller, Will Not Work in the Multiple Screen View Controllers
I have a single storyboard with 4 screens (segue to each ViewControllers).
An Open Url sequence WILL NOT WORK on any of the additional 3 screen ViewControllers.
It only works on the main View ...
0
votes
1
answer
72
views
Is it true that there is no way at all to subclass URLSessionDataTask, and if so is there a way to add an associated property?
I've always wanted to do something like
class URLSessionDataTask_Plus: URLSessionDataTask {
var obs: NSKeyValueObservation? = nil
// store the progress observer there
}
which would be ...
-1
votes
1
answer
249
views
Do you need weak self in the closure of a data task?
Say you have
extension APISingleton {
func items (
_ blah: Blah?,
completionOnMain: ( (_ status: Int, _ found: Blahs) -> ())? = nil
) {
let t = URLSession.shared....
0
votes
0
answers
82
views
Lagging Video Feed Using VNGeneratePersonSegmentationRequest in macOS Camera Extension App
I'm developing a macOS application using Swift and a camera extension. I'm utilizing the Vision framework's VNGeneratePersonSegmentationRequest to apply a background blur effect. However, I'm ...
0
votes
0
answers
57
views
iOS: Left bar button in navbar flashing when navigating back
I'm customizing the navbar and their bar buttons with a custom font using this code
let textAttributes = [NSAttributedString.Key.font: AppTheme.ptsansMedium(withSize: 17.0), NSAttributedString.Key....
-1
votes
1
answer
661
views
For a Live Activity, how can I put my widget bundle WidgetBundle "in" a Target
I have a UIKit app (it perfectly handles and does APNS), I add an ActivityAttributes and thus launch an activity.
So that's TestAttributes;
notice that is used in the Widget TestWidg;
and is used as ...
0
votes
1
answer
52
views
iOS - Show header view in 2 tableviews next to each other
I have a view controller that shows two tableViews side by side.
I have also a class (ButtonHeaderFooterView) that extends from UITableViewHeaderFooterView.
I want to show different titles for the ...
0
votes
1
answer
81
views
Extracting a String from a [String: Any?] by key
var annoying: [String: Any?]
To get the 'height' value, the best I could come up with is this,
let found: String = (annoying["height"] as? String? ?? "?") ?? "?"
That ...
0
votes
0
answers
110
views
unarchiveObject(with:) deprecated, is there a replacement when you are unwinding NOT a class but a vanilla [String: Any?]
req = ["a":nil, "b":3, "c":["d":3.3, "e":"e", "f":[]], "g":[]]
Traditionally ("if js can do it we can do it too!&...
1
vote
1
answer
41
views
Getting errors while using decodable extension in different module in Swift
I am facing issues while using init(from decoder: Decoder) in Model extension in different module.
I have model in Module 1 as below
public struct LabelModel {
public var value: String?
}
And I ...
-2
votes
2
answers
118
views
How do you, or can you, create and/or "adjust" an NSLayoutAnchor property?
Say you have some large complex custom view,
lazy var pinkThing: ..
lazy var greenThing: ..
And you want to
///For upstream views to use as they wish
var pinkCenterY: NSLayoutYAxisAnchor {
return ...
1
vote
1
answer
102
views
Run a loop inside a nested array in swift
I am trying to get result by using a for loop inside nested response by not getting the required result.
I have tried but not getting the desired response.
Required result is as below.
[
[["P-1 ...
0
votes
2
answers
139
views
Is there any built-in way to get the mantissa and exponent (the "scientific notation" or "E-notation" values) of a CGFloat in Swift?
I was stunned to learn there is no? immediate way to get the mantissa/exponent of a CGFloat in Swift.
(Note that I want the two values, NOT a string representation in scientific notation format.)
...
0
votes
1
answer
50
views
Is the only way to have draw#rect redraw, in cases where you want that done on any size change, indeed with setNeedsDisplay in layoutSubviews?
Say you're drawing a line in draw#rect in some view,
override func draw(_ rect: CGRect) {
guard let c = UIGraphicsGetCurrentContext() else { return }
c.move(to: CGPoint(x: 13, y: 13 ) )
c....
4
votes
1
answer
825
views
Store a reference to a TaskGroup or add to it outside of scope
I'm trying to replace DispatchGroup with a TaskGroup because I can cancel a TaskGroup... however I can't store a reference to a TaskGroup..
The methods withTaskGroup(...) and withDiscardingTaskGroup(.....
2
votes
0
answers
118
views
AVRoutePickerView() Bug
On my end showing same option "iPhone" and "iPhone". While this should be "iPhone" and "Speaker". Reply please, if found solution for this. This comes only when ...
0
votes
1
answer
230
views
Custom Circular Slider with gradient colour bar Swift
Here is what I am trying to do:
The screenshot is taken from Iphone:
Code:-
import UIKit
import MSCircularSlider
class HomeViewController: UIViewController {
@IBOutlet weak var lbl_Clock: UILabel!
...
1
vote
2
answers
74
views
Would there be a syntactic sugar -like way in Swift to make a "default member" of a struct (as if "hidden fields" added to a type)?
You have
typealias Stringish = String
var x: Stringish
func examp() {
x = "yo"
print(x)
}
and you have a zillion Stringish in your code base. You suddenly realize you need something ...
2
votes
2
answers
1k
views
How to do a Tuple extension in current Swift? It seems to be available experimentally
Some code,
typealias Brio = (String, String, String)
extension Brio {
static var divider: Brio {
return ("_", "_", "_")
}
static var isDivider: Bool {...
-2
votes
1
answer
287
views
No such module 'SwiftData'
I am trying to create a data model for an experiment project. However, I am unable to import SwiftData. I am using Swift 5.
import Foundation
import SwiftData
@Model
class WeatherDataModel{
var ...
0
votes
1
answer
78
views
Is it perfectly correct that this computed property will work like a "pointer" in current Swift?
Have a data source singleton with
class hugestuff ..{
var dataSources: [String: ThingWithIncrediblyLargeArrays] ..
var currentThing: String
}
ThingWithIncrediblyLargeArrays is indeed a ...
0
votes
1
answer
105
views
Is it absolutely the case that Swift >will not< deep copy a large array, when one "guard let" the array?
typealias Stuff = [[String]] // typically zillions of items
var stuff: [String: Stuff] = [:] // tens of these
When I deep copy† a Stuff,
spare: Stuff = original{
let line = $0.map{ $0 }
...
1
vote
0
answers
174
views
NavigationStackView .searchable modifier not visible when embedded in NavigationSplitView
can’t figure out why a NavigationStack with a .searchable modifier isn’t showing a search bar when embedded into a NavigationSplitView.
Here’s how I’m showing the Navigation on the homescreen for ...
0
votes
1
answer
317
views
Get height of a view inside ZStack in SwiftUI
I'm trying to get the height of a popup view that I added in my main content view. I tried using geometry reader, but it seems to be returning full height of the view. Am I doing something wrong here?
...
0
votes
0
answers
234
views
How to add axis titles with DGCharts in Swift?
We are updating our code to work with DGCharts v.4.0 (previously Charts) and our previously working solution (see below) for adding titles for the x and y axis is now no longer working, as "...
0
votes
1
answer
36
views
swift | Nothing in multiple TableView with custom cell
This is my code. I checked IBOulets connection, Identifier, class names.
and find some question and answer which on same boat. but didn't words.
what did I missed? Thank you for reading. :)
...
0
votes
1
answer
329
views
Xcode 15: After deploy build to TestFlight, fonts have another style
We did update macos and Xcode to the latest releases (macos Sonoma, and Xcode 15). After deploying our app to TestFlight we see strange issue that all custom fonts in application was changed from ...
1
vote
0
answers
65
views
xcode datatask not running
I am new in using swift5. I am going to integrate Apple Pay with my app, however the datatask seems not working cannot see any log from the console. Can anyone tell me what I am done wrong? also how ...
6
votes
2
answers
649
views
How can I change the source location of an OSLog Message?
I'm working on a company project that requires me to log to a specific server, but I want to log to the console simultaneously. I use a custom logging class that I can feed a log message, a log level, ...
0
votes
1
answer
75
views
QLPreviewControllerRepresentation does not conform to protocol UIViewControllerRepresentable
Im' new in swift and I want to understand why I got this error from my struct. I want to offer to my customer the possibility to show the file after the download.
Here is my class witch used for :
...
2
votes
1
answer
638
views
NSBatchInsert does not work for CoreData Transformable Attribute e.g. Dictionary<String, String>
CoreData doesn't import the data when using dictionaries in a transformable core data attribute. I'll attach screenshots of the setup and the project. Using a custom NSSecureUnarchiveFromData like [...
1
vote
1
answer
2k
views
Declining request for FCM Token since no APNS Token specified
I would like to generate notification to specific moment in my swift application but I got this message witch indicate me that apns token is not specified.
however I generate the certificate from ...
0
votes
0
answers
382
views
Swift Failed to associate thumbnails for picked URL file
I would like to understand what this error come from :
This the error from text :
2023-09-07 12:16:50.304646+0200 ML2V_IOS[4697:148814] [DocumentManager] Failed to associate thumbnails for picked ...
0
votes
0
answers
94
views
When I pick an image using UIImagePickerController, I am presented with AX Lookup problem - errorCode:1100
So firstly, when I present the image picker I get this error:
2023-08-03 16:47:45.979280-0700 MyAppName[7794:1889375] [AXRuntimeCommon] Unknown client: MyAppName
Then when I choose an image I get this ...