How to use CoreData in SwiftUI 4 👉 kzbin.info/www/bejne/i32YnqiBpKyWas0
@smwoody88 Жыл бұрын
First, thanks for the awesome video! In many of your replies you state that this is fixed in Xcode 14.1. Perhaps it has been addressed for some cases, but it seems to still happen using Xcode 14.2 when using MKCoordinateRegion as a Published variable. In addition, because MKCoordinateRegion is not Equatable (as pointed out by @martinmajewski in the comments), the solution you've provided doesn't work for this case. Here is a code snippet that has the same warning: ``` class ViewModel: ObservableObject { @Published var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 41, longitude: 14), span: MKCoordinateSpan(latitudeDelta: 1, longitudeDelta: 1)) } struct MapView: View { @ObservedObject var viewModel = ViewModel() var body: some View { Map(coordinateRegion: $viewModel.region) } } ``` Do you have the same problem and have a suggestion to solve? Or do you believe it is still just a bug?
@rebeloper Жыл бұрын
Yeah, I do have the same problem. What I ended up doing is use UIViewControllerRepresentable to grab it from UIKit. Here's the easiest realtime app I’ve ever built 👇 kzbin.info/www/bejne/qnekZGOmZtySrLM
@HeroTheOne Жыл бұрын
Same problem here
@dannymeyer249 ай бұрын
@@rebeloperI’m running into the same issue as OP, can you elaborate on how you did this? I clicked your link but that seems to be a video about fire base rather than maps. Thanks!
@StewartLynch2 жыл бұрын
Another fantastic video Alex. So clear and well presented. Thanks. I am wondering if you can answer this question though. If you add a buttonStyle to your button that toggles the isPresented value, you no longer get the error. For example, I just added .buttonStyle(.borderedProminent) and the error no longer is presented.
@rebeloper2 жыл бұрын
The warnig is indeed not presented if you add .buttonStyle(.borderedProminent) but it will pop up when you're going to dismiss the sheet presented with the dismiss environment (even if you put a button style on it) Strange issue. We'll have to wait and see what comes out of beta.
@edwardhasted3849 Жыл бұрын
This is the only explanation I have been able to find on this subject - very many thanks.
@rebeloper Жыл бұрын
You are welcome! Next Unlock the Power of Core Data Versioning! 👇 kzbin.info/www/bejne/iHXXfYqNpNhmmaM&ab_channel=Rebeloper-RebelDeveloper
@IceyMyst2 жыл бұрын
Hi I believe this explanation may be incorrect as I'm able to replicate the warning in situations that don't use a binding. It appears that the warning is only displayed when using the default button styling. If you change the button styling to .plain, it seems to remove the warning. I suspect that the default button styling is triggering multiple view updates and somehow is running the logic within a view update inappropriately.
@rebeloper2 жыл бұрын
The warnig is indeed not presented if you add .buttonStyle(.borderedProminent) but it will pop up when you're going to dismiss the sheet presented with the dismiss environment (even if you put a button style on it) Strange issue. We'll have to wait and see what comes out of beta.
@boonyawatl2 жыл бұрын
@@rebeloper My question is....should we apply the fix now or wait until Apple provides us with an update on this issue?
@ShooMPozitiV2 жыл бұрын
Just one video about this important thing. Thank you very much!!
@rebeloper2 жыл бұрын
Glad it was helpful! Share it with someone you think needs it. Next check out 6 State Mistakes Every Junior SwiftUI Developer Makes 👇 kzbin.info/www/bejne/b16VqI2pZ6dkadk
@johnappleseed69268 ай бұрын
Perfect title
@rebeloper8 ай бұрын
Thanks :) Next watch: SwiftUI Text - EVERYTHING You Need to Know 👇 kzbin.info/www/bejne/qHyol6Zrn5h0hKc&ab_channel=Rebeloper-RebelDeveloper
@paintopurpose Жыл бұрын
Can't we use pending changes instead? So in the view, when view rendering is happening, anytime you want to change an observed variable, you don't write to it directly...you'd have a struct that could have pending new values. Then after your view update has completed, simply trigger a func that will commit those pending changes to observed variables
@rebeloper Жыл бұрын
I don't know how we could do that. Next check out SwiftUI Navigation for Dummies 👇 kzbin.info/www/bejne/eqbKc4l8f56diKs&ab_channel=Rebeloper-RebelDeveloper
@lincolndickerson1293 Жыл бұрын
I have several views that have bindings to published vars that are acting strange which worked perfectly before XCode 14/iOS 16. No purple warnings just acting badly. Textfields only reflect one character then erase it when a second character is typed then may or may not show the third char. Never displays more than one. Which I can see as similar to the weird dismiss button behavior. This validates my suspicions that something pretty important changed. Things “seem” to work binding just one or two views levels deep. When there are several levels of subviews binding to a published var that is when things go wrong. Based on the structure of the data ,arrays of arrays, and the dynamic nature of the views based on the contents of those arrays binding to public vars worked very well. Hoping using the synching mechanism example presented here I will be able to adapt it work with Xcode’s current idiosyncrasies in my project. Thanks.
@rebeloper Жыл бұрын
Most probably you have issues setting up your data handling. I recommend taking a look at this video first: kzbin.info/www/bejne/qXbclKCpf9OjrKM Next check out How I HACKED My Brain To Learn Coding 👇 kzbin.info/www/bejne/aKWYfI2inrGVZrM
@lincolndickerson1293 Жыл бұрын
@@rebeloper if you were take the example you have shown here and passed the name through two or more views using bindings to create a complex view at the top you would see similar behavor to what you did with the dismiss button. The views I am working with worked fine before Xcode 14.
@rebeloper Жыл бұрын
Have you tried not passing them along as a Binding but having an EnvironmentObject? Next check out Why You Should Use The SwiftUI Coordinator Pattern 👇 kzbin.info/www/bejne/l5Kvg4aKbNl7fLM
@lincolndickerson1293 Жыл бұрын
@@rebeloper So when you have several many to one relationship being presented through ForEaches coordinating through an environment object is less than optimal but also on of the solutions I am sorting through
@ZorianaIvaniuk2 жыл бұрын
Amazing axplanation. This warnings is so annoying. But I don't understand why they removed binding. It's so useful. I hope it will be fixed in the next version of XCode
@rebeloper2 жыл бұрын
Agreed! It should have been fixed in iOS16.1. BTW Do you know how to properly name things in code? 👇 kzbin.info/www/bejne/n4myapaijdd1oJo
@apollocolorado Жыл бұрын
Great explanation. I have a question. In the beginning you say not to use a binding $ with a @Published property, but around 7:44 you use the line .onReceive(appService.$isPresented) { Why does that compile and not show the purple warning? Indeed .onReceive shows a compiler error without the $. Thanks!
@rebeloper Жыл бұрын
I'm parsing it into a State variable. Btw this has been fixed in the next version of Xcode. Next Learn About One Fatal Programming Mistake: Stop Making it a Hobby! 👇 kzbin.info/www/bejne/gobWqpV8fahnedE&ab_channel=Rebeloper-RebelDeveloper
@lululucaschae Жыл бұрын
The warnings are gone again on iOS 16.2 - does that mean we don't need to worry about fixing it anymore?
@rebeloper Жыл бұрын
Yes, it look like it has been fixed in iOS16.2 🎉 Also here are the Best Coding Habits to Adopt in 2023 👇 kzbin.info/www/bejne/boCZfmqlpJqlns0
@trevordevelops2 жыл бұрын
To be clear, is this a bug or how we will have to handle bindings from now (iOS 16) and on?
@rebeloper2 жыл бұрын
Looks like this has been fixed in Xcode14.1 (iOS16.1) so it seems it was a bug. If you want to launch a business as a developer don't miss this video: The One-Person Business Model (How To Productize Yourself) 👇 kzbin.info/www/bejne/m3iZYWafppt6ptk
@falcosolitario2 жыл бұрын
really thank you for you video. I was searching this kind of solution for 2 hours. But what do you mean "do not bind a published"???? is this for real? really worried about this
@rebeloper2 жыл бұрын
Let's wait for a few updates of Xcode. Maybe it's a bug. BTW here are 6 things I wish I knew about SwiftUI when I started 👇 kzbin.info/www/bejne/e4vdaoGCaa1ji8k
@abanoubghaly76852 жыл бұрын
Thanks for sharing. You are awesome. do this lousy behavior cause a crash? Because my app is crashing (inconsistently) after installing the Xcode 14.0 so is the purple warning a crash causer or not?
@rebeloper2 жыл бұрын
Inconsistently it does crash. Mostly it's about navigation. I'll release a new video soon on how to do it so the warning goes away. Aprox. 2 weeks. Till than: 🎉 Just updated StoreKitPro 👉 kzbin.info/www/bejne/Y5jOp4V_i6qNqdU
@martinmajewski2 жыл бұрын
This only works for Equatables! MapKit uses MKCoordinateRegion, which you cannot put into an ObservableObject class anymore, but you can also not use the .onChange modifier because MKCoordinateRegion is not Equatable.
@rebeloper2 жыл бұрын
Good point. It looks like this has been fixed in Xcode 14.1 Also here are 5 Tips for Writing BETTER For Loops in Swift 👇 kzbin.info/www/bejne/mX7LaaWrnbmMb80
@leunamvon2565 Жыл бұрын
how can we do that same extension function for all type of variables? otherwise we have to create a extension function for every use case
@rebeloper Жыл бұрын
This has been fixed already in an update, but I would say to use some sort of Generics 🤔 If you're a SwiftUI developer you will love: Unveiling The 10 Commandments of SwiftUI - #4 Will Surprise You! 👇 kzbin.info/www/bejne/aZ-rfGiZqbF2hKc
@VykingBoy Жыл бұрын
Even with this fix I still get these warnings ! Using Xcode 14.2 with Swift5.7.2 in a MapKit/CoreLocation app
@rebeloper Жыл бұрын
Yes, I know. MapView still has this issue. Maybe use UIKit for this, that is what I do in one of my client apps. Next Unlock the Power of Core Data Versioning! 👇 kzbin.info/www/bejne/iHXXfYqNpNhmmaM&ab_channel=Rebeloper-RebelDeveloper
@hunterhillegas49882 жыл бұрын
This seems like it has to be some sort of bug? It's a huge usability regression if not. I'll check the release candidate and if still an issue, talk to DTS.
@theo7882 жыл бұрын
Looks like it's still an issue in the RC...
@rebeloper2 жыл бұрын
RC still has this issue :( Next check out 6 State Mistakes Every Junior SwiftUI Developer Makes 👇 kzbin.info/www/bejne/b16VqI2pZ6dkadk
@santhoshVnair2 жыл бұрын
Great explanation and solution. Sounds like, this new warning is to protect the view from external dependency to a published variable - in order to limit uncontrolled view refresh. So, an improvement could be to throttle the View modifier that implements the sync.
@rebeloper2 жыл бұрын
Nice suggestion. This seems to be fixed in iOS16 though. BTW check out The BEST Side Hustles For Programmers in 2023 👇 kzbin.info/www/bejne/nGe7n4Fvd69-Z5I
@chrispugmire4 ай бұрын
I think this is the wrong solution in some situations. In my case at least the problem was changing the variables at the wrong time. Just change them in the onappear function and the problem goes away. I don't claim to understand the issue but I hope this helps someone.
@rebeloper3 ай бұрын
Thanks for the input. Have you seen my latest video? 👉 NavigationStack vs. NavigationCoordinator: You Won’t Believe the Difference! kzbin.info/www/bejne/bZfFaHaOqd5on5Y
@anasahalabi27492 жыл бұрын
This is now how we are supposed to code in swiftUI, this takes the whole point of the MVVM architecture, Apple has to create a patch update for this right? if not then we are doomed I believe.
@rebeloper2 жыл бұрын
Still there in Xcode14 :( Let's wait and see. BTW here are 6 things I wish I knew about SwiftUI when I started 👇 kzbin.info/www/bejne/e4vdaoGCaa1ji8k
@Arthur-eg7uy2 жыл бұрын
Life saver video!
@rebeloper2 жыл бұрын
Glad it helped! BTW this seems to be saved in Xcode 14.1 I guess we'll see. Next check out these Top 10 SwiftUI One Liners That Will Blow Your Mind 👇 kzbin.info/www/bejne/nXWziqp5gK-jm7M
@Arthur-eg7uy2 жыл бұрын
@@rebeloper actually no Xcode 14.1 beta 3 still has this issue! I worked on it today!
@rebeloper2 жыл бұрын
Thanks for letting me know. Use the "hack" provided :) Check out How I CODE For HOURS With NO Breaks 👇 kzbin.info/www/bejne/o4iveqWcl9h3oK8
@dugrut1325 Жыл бұрын
I get this error with Map(..., I've tried many things to stop or reduce the errors, It had nothing to due with changing @Published values
@rebeloper Жыл бұрын
If you need to I can take a look at your code on a mentoring session. Book your call here: rebeloper.com/mentoring BTW check out my lates video 👉 2023's Must-Have Xcode Extensions: Revealed Here! 👇 kzbin.info/www/bejne/amKXaoWraa1nmKs
@thientoan010111 ай бұрын
awesome
@rebeloper11 ай бұрын
Glad you liked it! Now get ChatGPT 4 for Free in VSCode for iOS and macOS app development 👇 kzbin.info/www/bejne/b6HIlJtqnruHjbc&ab_channel=Rebeloper-RebelDeveloper
@nickpavlov4012 Жыл бұрын
Wait, I thought @MainActor fix that no? What is difference between @MainActor and what he did?
@rebeloper Жыл бұрын
Well with iOS17 we will not have to worry about this at all :) Xcode 15 Beta: How To Download And Install 👇 www.youtube.com/watch? v=4gwW9pq_BT8&list=PL_csAAO9PQ8agVtPZVAQFhsexNJBPSteh&ab_channel=Rebeloper-RebelDeveloper
@nickpavlov4012 Жыл бұрын
@@rebeloper thanks for respond Rebeloper . Wow really? Thanks for info I’ll check it out
@rebeloper Жыл бұрын
Welcome! Next watch What's New in Xcode 15 Beta 👇 kzbin.info/www/bejne/gHrKdnWCf5t2a6M&ab_channel=Rebeloper-RebelDeveloper
@perhapsyes24932 жыл бұрын
I regret switching our app to SwiftUI. So. Fucking. Much.
@rebeloper2 жыл бұрын
This seems to be fixed in Xcode 14.1 beta 3 :)) Next: Make Sure You Always Get the Best Error Alerts! 👇 kzbin.info/www/bejne/jIjKi2xve7moeLc
@victorchoi38 Жыл бұрын
I don't like this fix. Apple must fix this.
@rebeloper Жыл бұрын
They already did :) Next watch Master Keychain Access Like a Pro using SwiftUI Property Wrappers 👇 kzbin.info/www/bejne/eGirc4CPeqqNqsU&ab_channel=Rebeloper-RebelDeveloper
@hypernikomen Жыл бұрын
For me, the solution was DispatchQueue.main.async: `DispatchQueue.main.async { viewModel.updateMyPublishedProperty(with: value) }` (Xcode 14.2).
@rebeloper Жыл бұрын
Thank you for sharing :) Next find out the BEST WAY to Read and Understand Code 👇 kzbin.info/www/bejne/ZpzLo5Z8o9-bptU&ab_channel=Rebeloper-RebelDeveloper