|
I am trying to disable a button based on a computed property from the View Model, but is only disabled after the view is reloaded. This is the View Model :
This is how I am disabling the button .
This is the Core Data View Model :
NOTE : It works, but only when the view is reloaded. How can i make this work?. I've tried |
|
hi, one obvious problem is that you are writing
or
you should never be setting the value of an another problem is that there are too many instances of models:
none of these models is being shared across views. so i think you need to work a little bit on your idea of modeling the data. my suggestion to start: if hope that helps, DMG |
|
This is an observation I would share with my development team during a code review. My team would require you to rewrite this awkward code:
The main issue here is the var name This is exactly the type of business logic that belongs in your data model. The model is the best place to determine if the name has content or is empty. Then you can decide if a non-empty value is valid. For example, X3k2b] probably is not a valid first name. What I think you're going for is a person's first name as a string. If this is the case, put all that logic in your data model. Then, whenever you need to display a person's first name you just reference the person's object from the data model. Maybe something like this:
|
|
@twostraws has a great article here about value objects. He uses authentication as an example. See > User Authentication This can help you get back on track. |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.