140 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
-1
votes
2
answers
106
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月30日T04:00:00Z")
Sometimes as a Unix timestamp (...
0
votes
1
answer
27
views
Errors in creating a property wrapper
I've been trying to wrap my head around Swift's property wrapper. The documentation's code, defined as follows, works fine:
@propertyWrapper
struct TwelveOrLess {
private var number = 0
var ...
3
votes
1
answer
201
views
Swift property wrapper value in struct not updating view
I just learned about Swift's property wrappers from Nick Sarno's YT video and they seem pretty cool. I'm investigating and I created a property wrapper to uppercase a string:
@propertyWrapper
struct ...
0
votes
0
answers
42
views
Pass data to next view using Binding<T?>
I need some help from my colleagues because I can't handle it on my own. I am stuck.
I have a database on Firebase with training programs in it. ProgramsID loads the list of trainings. Here's how the ...
3
votes
1
answer
292
views
Property wrapper like dynamic property / TextField / SwiftUI
I need the wrappedValue in TextField to be immediately uppercased as text is entered.
In this video, it works:
https://www.youtube.com/watch?v=aQE3kbCA0nk&ab_channel=SwiftandTips
But here, for ...
-1
votes
1
answer
166
views
How to force SwiftUI view to reinitialize but not recompute(rerender) body
Body will recompute(rerender) only when source of truth changes far as I know.
Question 1:
Will changing of source of truth ALWAYS trigger reinitialization and rerender combined?
Question 2: Is it ...
-1
votes
1
answer
115
views
How to force non-optional type (for array element) on compile time in Swift? [closed]
struct MyStruct {
@ArrayOfNonOptionalElements var arr: [SomeNonOptionalType]
}
where @ArrayOfNonOptionalElements is a propertyWrapper.
So, how to force non-optionality for the type inside? Is it ...
0
votes
3
answers
159
views
What is the difference between (@StateObject & @StateObject) and (@StateObject & @ObservedObject) in Parent and Child Views
@StateObject & @StateObject in Both Parent and ChildView
import SwiftUI
class Counter: ObservableObject {
@Published var count: Int = 0
func increment() {
count += 1
}
}
...
-2
votes
1
answer
121
views
Binding with a ternary between parent/child views in SwiftUI [closed]
Consider this code in which I'm trying to continuously animate a set of circles from red to blue:
struct ContentView: View {
let timer = Timer.publish(every: 1.0, on: .main, in: .common)....
2
votes
2
answers
460
views
Swift Property Wrapper on Struct
I am struggling to create a swift struct, where I can use a property wrapper to decode some JSON that sometimes requires a value to conform to a specific type, but other times may become a dictionary ...
1
vote
0
answers
102
views
SwiftUI Alert setting presentation condition true in it's button action closure not showing the alert again
So the thing I want to do is that I have an api call if it fails I show an alert with message, OK button and Retry Button.
Everything is working good but when I do retry it don't shows the alert again ...
7
votes
1
answer
2k
views
Can't use Property Wrappers on a class marked with @Observable
I have a class which is similar to:
final class Person {
@Resettable var name = "John Doe"
func revertName() {
name = $name
}
}
@propertyWrapper
struct Resettable&...
0
votes
1
answer
380
views
Swift: Union Type in Property Wrapper
In Swift, you can specify a union type using an enum. For example:
enum IntOrString {
case int(Int)
case string(String)
}
Now I want to write a property wrapper, which I can apply to ...
0
votes
1
answer
189
views
SwiftUI - immutable @State variable when change it "from outside" via UIHostController
Situation
During migration of some UIKit view classes to SwiftUI, I have faced next case:
I have a simple view class, responsible for data fetching and displaying. Its structure is pretty simple and ...
-1
votes
1
answer
109
views
How to have @State that is an array with the size that depends on a FetchRequest
I have an app that is outlined in the following. Most of the code I have adapted from https://www.hackingwithswift.com/books/ios-swiftui/how-to-combine-core-data-and-swiftui
But the part I have ...