property-wrapper Questions
4
Solved
I want to have an optional @ObservedObject in SwiftUI but I keep getting a compile time error of.
Property type 'AModel?' does not match that of the 'wrappedValue' property of its wrapper type 'Obs...
Weihs asked 12/4, 2021 at 18:33
3
Solved
I was wondering how would I be able to pass down a @FocusState to another view. Here is some example code:
struct View1: View {
enum Field {
case username, password
}
@State var passwordText:...
Rattletrap asked 28/11, 2021 at 6:40
3
I wish to apply a custom property wrapper to a variable already wrapped in @Published, nesting them like
(A) @Custom @Published var myVar or
(B) @Published @Custom var myVar
(notice the application...
Terylene asked 9/2, 2021 at 12:9
1
Solved
I'm trying to make a property wrapper similar to Combine's Published one(for my project needs), but with ability to modify the wrapped property by sending a value to a publisher, stored in projecte...
Strage asked 16/3, 2023 at 19:38
3
Solved
I have recently been experimenting with swift property wrappers and wondered if there was any way of composing them together in order to achieve a more modular architecture. E.g:
@WrapperOne @Wrap...
Erasion asked 14/1, 2020 at 17:50
2
I keep the Model as a Published var in the ViewModel and Observe it from the View.
When the model process goes into a background thread, if you publish the model value, the Xcode thread check...
Musketeer asked 8/1, 2022 at 4:42
5
Solved
Problem
In Order to achieve a clean look and feel of the App's code, I create ViewModels for every View that contains logic.
A normal ViewModel looks a bit like this:
class SomeViewModel: Observ...
Outspan asked 8/5, 2020 at 10:15
2
Solved
Given the setup I've outlined below, I'm trying to determine why ChildView's .onChange(of: _) is not receiving updates.
import SwiftUI
struct SomeItem: Equatable {
var doubleValue: Double
}
stru...
Veasey asked 12/2, 2022 at 0:56
1
Solved
I understand that @Binding is a property wrapper and I believe that Binding<Type> is a form of type casting but what is the difference in practical terms?
For example declaring a var like:
@B...
Oxbridge asked 11/2, 2022 at 0:18
1
Solved
I'm using a property wrapper to decode the strings "true" and "false" as Booleans. I also want to make the key optional. So if the key is missing from the JSON, it should be dec...
Especially asked 15/11, 2021 at 17:47
4
I'm attempting to create a custom property wrapper supported by SwiftUI, meaning that changes to the corresponding properties values would cause an update to the SwiftUI view. Here is a simplified ...
Tutt asked 3/1, 2020 at 14:14
1
Solved
I have created a "lock" in Swift and an Atomic property wrapper that uses that lock, for my Swift classes as Swift lacks ObjC's atomic property attribute.
When I run my tests with thread ...
Logography asked 14/4, 2021 at 20:3
4
Solved
I am trying to make a ObservableObject that has properties that wrap a UserDefaults variable.
In order to conform to ObservableObject, I need to wrap the properties with @Published. Unfortunately,...
Annul asked 25/11, 2019 at 17:8
1
Solved
Trying to implement a custom property wrapper which would also publish its changes the same way @Publish does.
E.g. allow my SwiftUI to receive changes on my property using my custom wrapper.
The ...
Hogue asked 25/1, 2020 at 18:54
1
Solved
I have been reading about the property wrappers in SwiftUI and I see that they do a great job, but one thing which I really don't get is the difference between @EnvironmentObject and @ObservedObjec...
Puffery asked 10/8, 2020 at 16:5
1
Solved
The following code reproduced the error:
import SwiftUI
struct ContentView: View {
@State private var number: Int = 5
var body: some View {
NavigationView() {
VStack(spacing: 20) {
Navigatio...
Shuster asked 3/6, 2020 at 11:17
1
I'm using Swift property wrappers to define something like:
@MyWrapper var foo: Int
And in the implementation of the property wrapper, I'd like to access the name of the variable, foo, as a stri...
Kentiga asked 26/10, 2019 at 22:51
1
Solved
I am using a property wrapper to save my User Default values. On iOS 13 devices, this solution works great. However on iOS 11 and iOS 12, the values are not being saved into User Defaults. I read t...
Gatian asked 24/12, 2019 at 20:10
1
How can I use Binding(get: { }, set: { }) custom binding with @Binding property on SwiftUI view. I have used this custom binding successfully with @State variable but doesn't know how to apply it t...
Helmuth asked 12/12, 2019 at 19:58
1
Solved
We now have a new way to make a lazy variable. It is described in swift-evolution/proposals/0258-property-wrappers.md:
@propertyWrapper
enum Lazy<Value> {
case uninitialized(() -> Value)...
Deponent asked 29/10, 2019 at 6:54
2
Solved
This tutorial by Apple about SwiftUI uses a dollar sign to bind data, and I‘m having trouble finding more information about this data binding in SwiftUI.
Toggle(isOn: $showFavoritesOnly) {
You...
Faceharden asked 11/6, 2019 at 20:16
1
© 2022 - 2024 — McMap. All rights reserved.