Questions tagged [swift5]
Use this tag only for questions directly related to changes in version 5 of Apple's Swift programming language. Use the tag [swift] for more general language questions, or the tags [ios], [cocoa], [apple-watch] etc. for questions about developing on Apple platforms.
swift5
3,123
questions
0
votes
0
answers
15
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
25
views
File size on iOS: does the usual technique `... .fileSize` give the bytes of the content, or, the "rounded" size in re drive formatting?
In iOS to grab the size of a file,
file.resourceValues(forKeys: [.fileSizeKey]).fileSize
(Example, size of a whole directory )
In short how does the chunk size of affect this result? Is the result ...
0
votes
0
answers
26
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....
0
votes
0
answers
11
views
Need help on onesignal sdk 5.2.3 swift5 [closed]
Getting error while initialized one signal in swift5 code base.
ERROR: OSUserExecutor create user request failed with error: Optional(Error Domain=OneSignalError Code=401 "(null)" UserInfo={...
-1
votes
1
answer
64
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
36
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
68
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
42
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!&...
0
votes
0
answers
24
views
How Do i prevent wkwebview loading full screen?
I am loading an i frame url in webview but when i click on play button it is loading to full screen but i need to stop that
Here i need to load the url with in the webview frame only it should not go ...
1
vote
1
answer
30
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
64
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
87
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
56
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
30
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....
3
votes
1
answer
161
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(.....