How to use Core Data with MVVM Architecture in SwiftUI | Continued Learning #15

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

Комментарии • 137

  • @michaelmarx1405
    @michaelmarx1405 3 года назад +6

    I litterly spend hours researching this and you saved me in 1/2h. Thank you so much

  • @a.h.m1365
    @a.h.m1365 3 года назад +20

    when you create entity in core data model be sure after that to press cmd + s to save cuz Xcode mostly do not save file extension xcdatamodeld automatically

  • @felipemarques7531
    @felipemarques7531 2 года назад +1

    "I'm just doing this again for ppl who are just joining". Proof that heroes don't always wear capes, folks.

  • @moisesscn
    @moisesscn Год назад +2

    Hi Nick! I'm looking for a few adventures in the mobile world as a senior full-stack web developer and thanks to your courses I've been learning a lot! Already built my first simple app and I'm planning to tackle a second one soon. Thanks to your patience, awesome teaching skills, and great content, I feel like I have all I need to go into these waters, as I don't always understand Apple's documentations. Thank you very much for putting such an effort to this, enabling myself and many other people like me.

  • @tomqin3685
    @tomqin3685 2 года назад +3

    This is the third time I've been watching this series, and every time I finished the course, I always learn new things! Thank you, Nick!🥳🥳

  • @kjlee7826
    @kjlee7826 3 года назад +1

    Though I learned to use CoreData somewhere else, your coding style is much more realistic that I can always learn something. That is why I keep watching your tutorials even on topics that I am familiar with. I am so thankful for your teachings of good qualities. Thank you!!

  • @TheCodingRaconteur
    @TheCodingRaconteur 9 месяцев назад

    This changed everything for me - first time user of coredata

  • @philslinkee
    @philslinkee 2 года назад

    Glad I found your video - I was really struggling with Core Data in the MVVM pattern - I haven't found anywhere else that explains it so well - Thank you!

    • @indiekiduk
      @indiekiduk 2 года назад

      It's because MVVM isn't a good idea in SwiftUI it pretty much defeats the purpose of the view struct and property wrappers

  • @manuelsteele8030
    @manuelsteele8030 Год назад

    I come from a deep background in data warehouses, relational databases, and REST API testing with backend databases. I have worked with both SQL and no-SQL databases. In data warehouse development and testing, the ETL concept is key. The developer typically should create a software design specification with a source-to-target matrix such that any data transformations are addressed. The transformations or the "T" in "ETL" for extract, transform and load can get somewhat complicated. I have seen software defects rooted in transformation errors. So, the MVVM model is ideal in separating the architecture into components such that the ViewModel deals with transformations. So, the MVVM video is great. I appreciate Nick's attention to details in his presentation on how MVVM works. Now, the only area that gets little coverage in my opinion for multiple Core Data tutorials from either Nick or other influencers is the concept of many-to-many tables. In relational SQL, the SQLite database with many-to-many tables should have an ER implementation such that the many-to-many relation uses a hybrid intermediate table with primary keys from both tables. This allows the queries and inner joins that could be done. I was able to implement that easily using MySQL and SQLite with PyQt. I haven't seen any Core Data video that goes from the ER relation of a many-to-many relation with two tables and primary keys and discusses how that "intermediate table" with primary keys from both tables is addressed in Core Data. The Microolap Database Designer web page has this definition "The only way to create many-to-many (N:M) reference between two tables in MySQL is using an intermediate table, which records set association between primary keys of first table and primary keys of second table." I haven't seen a Core Data tutorial that addresses that in its many-to-many tables by going from the ER software design to the code implementation. Usually, the influencers just write code without ever addressing the written design of an ER model. Such development patterns are ripe for errors in my experience with testing data warehouses. I worked with Informatica developers and was trained by a guy with about 45 years of experience in ETL database development.

    • @manuelsteele8030
      @manuelsteele8030 Год назад

      Update: I found additional resources that help me to understand what is going. The "many-to-many" relationship of table A to table B where an intermediate table C with primary keys from both A and B is replaced by a relation in the graph object model. I found a website that shows the checklist and a couple of other videos. So, I figured out how to make a traditional ER model then convert it to a graph object model which can then be implemented in SwiftUI Core Data. That ER to graph model conversion is usually missing in most Core Data videos. The typical computer science departments focuses on ER for training on databases. Given that graph object diagrams are largely untaught with comprehension, this can lead to design errors badly. The article I found is "RDBMS & Graphs: Relational vs. Graph Data Modeling".

    • @chadgoodyear7905
      @chadgoodyear7905 11 часов назад

      @@manuelsteele8030thanks for that. And you know you can get to the SQL database underlying Core Data if you need to for testing.

  • @tas_araf
    @tas_araf 3 года назад

    I know you probably won’t see this , but thank you so much seriously. I didn’t know where I could learn SwiftUI and where to start but you help out so much . You deserve so much more subs

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +2

      Hahah you don't know yet... I read all the comments! Thanks for the comment Tasawar. Happy to help!

  • @thaisfernandes7498
    @thaisfernandes7498 3 года назад +5

    You always have a video for something I need to learn!
    Thank you so much for these videos! You teach really well. :)

  • @MarvelousLXVII
    @MarvelousLXVII 2 года назад

    Excellent video. I prefer this method rather than the last video.

  • @runpress.runningcompetitio2452
    @runpress.runningcompetitio2452 3 года назад +2

    Thanks Nick! Simple and straightforward solution to the question of replacing @FetchRequest with ViewModel @ Published. It is unclear why Apple itself did not solve this issue, leaving the developers with a good, but primitive @FetchRequest

  • @HilaProdomo
    @HilaProdomo 3 года назад +2

    This is the video I was looking for! Thank you very much 🙂

  • @phrax
    @phrax 3 года назад +1

    Excellent and clear. It was very easy to understand how you fit together View, View models and model.

  • @MrTalhakhan01
    @MrTalhakhan01 3 года назад +2

    Beautiful explanation

  • @Nunny25
    @Nunny25 3 года назад +1

    Hi Nick, thanks. It was clear for me. What I missed was possibility to sort data as you explained in the previous video.

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +1

      Oh sorry I didn't mean to miss that haha. It's pretty much the same logic that you can add to the FetchRequest. If you watch the next video, I believe we will cover sorting and filtering using CoreData with the MVVM approach.

  • @danfeinstein4424
    @danfeinstein4424 3 года назад

    Absolutely essential stuff ignored by some paid subscription programs. Thank you.

  • @MrJacklightning
    @MrJacklightning Месяц назад

    Hello! Thank you so much for the cool material! That's what I was looking for my project! You are the best!

  • @frankz2933
    @frankz2933 2 года назад

    I super love your programming style.

  • @Yani-jv4pt
    @Yani-jv4pt 3 года назад

    Definitely your explaination is very good. Easy to understand. Thanks!

  • @BSharing09
    @BSharing09 2 года назад

    Your explaination is so clear and excellent. Thank a lot.

  • @alexcai4
    @alexcai4 2 года назад

    Brilliant video, super clean!

  • @adamkhan1613
    @adamkhan1613 2 года назад

    Your computers fan was running faster than R2D2 at the end of end game

  • @adamkacha3823
    @adamkacha3823 2 года назад

    Exactly what I was looking for. Thank you so much!

  • @dugrut1325
    @dugrut1325 2 года назад

    YES, loved the video, help immensely, I also put this in the code: savedEntities = savedEntities.sorted(by: { $0.name ?? "missing name" < $1.name ?? "missing name" })
    to sort .name, so I did learn something. Thanks again

  • @elemento_arts
    @elemento_arts Год назад

    Amazing stuff Nick. A video showing how to connect/save this database to the user's iCloud storage would be really helpful. (note: not iCloudKit)

  • @coffeeCatPeanutDust
    @coffeeCatPeanutDust 3 года назад

    Thanks Nick. Very good video!

  • @dugrut1325
    @dugrut1325 2 года назад

    I'm back... round#? ... who can remember. Every new app, time to rewatch this video. Thanks

  • @danielwatson6529
    @danielwatson6529 3 года назад

    This vid changed my life thanks bro

  • @ClintonSiegel
    @ClintonSiegel 2 года назад

    Super helpful! Thank you!

  • @bhagyashingale5663
    @bhagyashingale5663 3 года назад +5

    Correct me if I'm wrong. If you were to reference the view model as Observable/stateObject in multiple views you would end up instantiating CoreData multiple times from each view. This behaviour doesn't seem optimal. Solutions may involve declaring it as a struct or passing it down as an environment object from the main view.

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +3

      Hey bhagyash! You are correct! So in a real app, you could initialize the Core Data class when your app loads and then you would "inject" it into the view model by passing it into the View and then into the ViewModel initializer. However, I haven't covered Dependency Injection on my channel yet!

    • @bhagyashingale5663
      @bhagyashingale5663 3 года назад +2

      @@SwiftfulThinking I see, I think it's better to learn the right way from the start especially when dealing with shit like core data.

  • @drewalthage
    @drewalthage 2 года назад

    Awesome!!!

  • @brucknerdevilliers
    @brucknerdevilliers 2 года назад

    Thank you! You saved my bacon.

  • @thetrinitysolution9631
    @thetrinitysolution9631 3 года назад

    Hey, Nick. Not sure if you saw my previous question yet but if you did, I found a solution so please disregard. It appears as if replacing an existing project with a new project of the same name (using the "Replace" button), interferes with the indexing. Creating a completely new project with a new name fixed the problem.
    Thanks for everything you're doing. Your videos are an invaluable resource.

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад

      I am happy to hear you figure it out! Glad you're enjoying the course. Thanks for watching.

  • @toastrecon
    @toastrecon 2 года назад +1

    Thanks, Nick! I've been watching many videos on how to implement this, and it's been interesting to see the different styles. I'm guessing that if you had multiple vms that needed to listen to a persistentContainer, you'd put the container in some kind of manager, and then pass the context around to the several vm's using observableObject and @State to keep things in sync?

    • @SwiftfulThinking
      @SwiftfulThinking  2 года назад +3

      Hey David! That’s pretty close. I would create a class that has the persistentContainer and all the CoreData functions.. and then create a manager class. The manager class will hold the reference to the core data class. Then pass the manager to your VMs. The VMs call functions in the manager, which is essentially a funnel to call functions in the CoreData class. This creates an abstraction layer that will decouple the app from CoreData

    • @toastrecon
      @toastrecon 2 года назад

      @@SwiftfulThinking awesome! I’ll give that a shot. Thanks!

  • @mpbonaventura
    @mpbonaventura Год назад +1

    Hi Nick, loving your videos. I'm using Xcode version 14.3, and for the life of me I cannot figure out how to get the colour literals to work the way shown in your videos. I cannot get the picker with all of the pencils in it to appear. Any tips?

    • @AvantjerTube
      @AvantjerTube Год назад

      Yes, it seems that color literals no longer work, (in latest Xcode), as they do in Nick’s tutorial. 👎

  • @cliffcri
    @cliffcri Год назад

    Thanks for the vid.. Super helpful...
    Quick question though since it wasn't included in the video.. The delete func was super simple however should I need to delete all of the data, should I loop on the entity one by one and then delete? Is there any other easy ways to do it like container.viewContext.delete(.all)?

  • @emrah309
    @emrah309 2 года назад

    amazing

  • @abdouett3676
    @abdouett3676 3 года назад

    Great work! Thank you

  • @ZeakZac
    @ZeakZac 3 года назад +2

    Hi Nick, thanks for this video! I have a question though. I want to implement Core Data in MVVM way as you do, but what confuses me is when I check the box Core Data when creating new project, there's a file Persistence.swift that has persistent controller, and I can't understand where it belongs. Is that ViewModel? Is it okay that it's struct and not class like you did with CoreDataViewModel? Is there a way I can keep this Xcode automatically created file but keep MVVM architecture like you have? Or should I start from scratch like you do in this video and not make Xcode create that Persistence.swift file?

    • @KimbrellBrad
      @KimbrellBrad 3 года назад +2

      I am no expert but every course I've taken on Swift every instructor has told us to never use those checkboxes for CoreData or Testing. Not sure if that is so we really learn how to implement those items or if the files created are so problematic in many cases? And I'm talking high-quality instructors like Sean Allen, Paul Hudson, Meng To of DesignCode, Ray Wenderlich's courses I've taken, Stewart Lynch, etc. So I am curious as well. ...

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +1

      Hey Terry! The Persistance.swift file is just a convenience thing that Apple gives us. If you look at the code in Persistence.swift, almost all of it overlaps with the CoreDataViewModel that we built in this project. In production, we would probably separate the ViewModel logic from the CoreData logic. We do something like that in the next video in this series, where we create a CoreDataManager class, which would be the same as the Persistance.swift basically!

    • @ZeakZac
      @ZeakZac 3 года назад

      @@SwiftfulThinking Oh, thanks Nick! I didn't see next video, my bad. I see now you've created CoreDataManager and then made an instance of it in the ViewModel! Nice! Exactly what I wanted to know - how that persistence blends in with MVVM! Gonna keep watching that video, very interesting

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад

      @@ZeakZac Yes, exactly! That’s going to be another step towards a better approach. After that, instead of crating the instance inside the ViewModel, we would actually create it early on in our app architecture and then “inject” the instance into the ViewModel. I haven’t done that in this playlist because I only recently covered Dependency Injection in the Advanced playlist lol

    • @ZeakZac
      @ZeakZac 3 года назад

      @@SwiftfulThinking Ohhh, I see. I'll check that video as well then. Thank you!!!

  • @supreme9187
    @supreme9187 3 года назад +1

    Thanks for the video very insightful! I had a question about core data, the way you had it it set up every time someone added an item it would make a whole new entry basically an array. For my use case I want the user to be able to set one value and have that persist within one object . Is there any modification you would suggest for this or is it just a limitation of entities? not sure if this is clear but I want the user to pick a number and have that be the only data that is saved associated with its key in one persistent object. Hope this is clear
    Thanks once again

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад

      Hey Supreme! Yea, we are basically doing that already. If you ignore the fact that we are saving an array of fruits and just use 1 single fruit, the code would be the exact same.

  • @fvh500
    @fvh500 Год назад

    Hi Nick, great video. How can I set a sort type in the MVVM? Say we have two string attributes defined in one entity. I want to creat two lists, one sorted alphabetically on one attribute and a second list sorted alphabetically in the second attribute.

  • @Максим-ш7х4й
    @Максим-ш7х4й 3 года назад +1

    Thanks Nick)

  • @Totokwa
    @Totokwa 3 года назад

    Amazing tutorial!

  • @nikodemeroutis
    @nikodemeroutis 2 года назад

    Hi everyone ! First of all, thanks Nick for what you are doing ! I was asking myself if is it possible to have an array of string [String] in the core data ?
    Thanks for all Nick !

  • @Westmaner
    @Westmaner 3 года назад +1

    Nick thanks for your amazing series. I have tried to incorporate cloud kit sync to what you have here, but I am unable to get auto synch to work. Could you cover that topic?

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +1

      Hi Tim, thanks for the comment! I'm planning on doing a CloudKit series but it won't be for a few weeks. There's so much to cover with CloudKit that it's hard to do a quick video like this. The code structure should be pretty similar to regular Core Data though

    • @christinakrogmann
      @christinakrogmann 2 года назад

      @@SwiftfulThinking @Westmaner, II wanted to ask if you came up with a solution until today? I did the same as described in the MVVM video. Afterwards, I wanted to synch with CloudKit. Although, I did all steps necessary for that, the data is not showing in the dashboard. Ideas what I might be missing?

  • @fsdolphin
    @fsdolphin 3 года назад +1

    Very good tutorial. Do you know if there is a way or make sense to use @FetchRequest and @FetchedResults with MVVM? Or it's not recommended? Thanks a lot!

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +1

      @FetchRequest doesn't work with MVVM. It's great for getting started but I would probably not use it in production.

    • @fsdolphin
      @fsdolphin 3 года назад

      @@SwiftfulThinking Cool, thanks a lot!

  • @serhii_rs
    @serhii_rs 2 года назад

    Hi, Nick! Thanks for the video!
    I have one question - why do you use CoreDataViewModel in one file with CoreBootcamp View? Is it possible put CoreDataViewModel to separate file with model file like CoreDataModel and call its methods (add, edit, delete) from separate View file file (like vm.add(), vm.delete() etc) ? Will be published properties (for refreshing list items) work properly in this case?
    Thanks in advance!

    • @ColeDano
      @ColeDano 2 года назад

      Yes you can totally do that. It's just far faster to demonstrate everything from a single file, and easier for us to see what happening in the context of a RUclips video.

  • @happyuser109
    @happyuser109 3 года назад

    subscribed! great tutorial

  • @mourbatsalim4830
    @mourbatsalim4830 2 года назад

    Please Nick if we have Int property witch integer type should I choose?

  • @nizamitagiyev705
    @nizamitagiyev705 2 года назад

    It would be wonderful if you in next videos cover the theme of migration in Core Data. Downloading data from internet with image url and save that data in Core Data with image.

    • @SwiftfulThinking
      @SwiftfulThinking  2 года назад +1

      You should save images to the FileManager and only the image url in CoreData

    • @nizamitagiyev705
      @nizamitagiyev705 2 года назад

      ​@@SwiftfulThinking Got it! Thanks 🤙🏽

  • @garychen8185
    @garychen8185 3 года назад

    Quick question: so to follow MVVM pattern, we shouldn't use @FetchRequest wrapper?

  • @katesychenko
    @katesychenko 2 года назад

    Thanks a lot!

  • @cinquain0
    @cinquain0 3 года назад

    This video was badass

  • @WattsnabbAB
    @WattsnabbAB 6 месяцев назад

    Hi. Do you have a video on how to handle when you inject coredata in the begining and so i have one instace of it in the whole app? I have problem with that ritght now and when i change one thing the other get default values and i get this message in terminal.
    Accessing StateObject's object without being installed on a View. This will create a new instance each time.
    I want also to say thank you for you great videos! They really help!

    • @SwiftfulThinking
      @SwiftfulThinking  6 месяцев назад +1

      You would take the Core Data code and move it into its own “CoreDataManager” class and then pass that class into the different ViewModels.

    • @WattsnabbAB
      @WattsnabbAB 6 месяцев назад

      @SwiftfulThinking thanks for awnsering. Have made it and it work fine. To much gpt haha.
      Thanks again for you good videos. Really good content. I'm a computer science student from Sweden doing a school project so really good to have many great videos for my education :)

  • @joshk5582
    @joshk5582 2 года назад

    My core data functions very well BUT I can NOT figure out how to make textfields that can bind to the entities. I want each entity in the list to bind to textfield in that row that will allow modification of one of the entity's attribute values.
    I have spent about 20 hours this week trying to figure out this simple issues, any guidance would be SO appreciated. I have watched all of your core data viedos but don't understand how to apply what I know to this specific scenario.

  • @mr_Multitask
    @mr_Multitask 8 месяцев назад

    Thanks!

  • @co48756
    @co48756 2 года назад

    I am struggeling with this. I already have a MVVM project and am trying to use core data. But the new entity conflicts with my existing model. I don't know how to integrate the two so to say.

  • @gabrielrml
    @gabrielrml 3 года назад

    So 'on update' how would we load the name of the fruit in the list which has been tapped - into the textFieldText so it can be edited and resaved? Please

  • @vncsnts_
    @vncsnts_ Год назад

    Shouldn't the CoreData Stuff be separated into a Service class? and then DI EnvironmentObject? I hope there is a proper tutorial for that as sometimes Im confused what is the proper way with MVVM.

  • @TheFistRZ
    @TheFistRZ Год назад

    Very good video! But what do I do if I want to have two data models? I have tried but the app crashes and I get this error: "The fetch request's entity 0x2812288f0 'TheItems' appears to be from a different NSManagedObjectModel than this context's"

  • @ChristianHancke
    @ChristianHancke 3 года назад

    Thank you so much 😍

  • @karthikeyanramasamy8302
    @karthikeyanramasamy8302 2 года назад

    if i am going to use coredata handler(like fetch, add, delete) in viewmodel or model, i couldn't use @fetchrequest property wrappers, am i right?

  • @natgenesis5038
    @natgenesis5038 2 года назад

    My Reference 27:00

  • @wahhmann123
    @wahhmann123 9 месяцев назад

    is it better for the CoreData methods to be a singleton? Or it's own class?

  • @philslinkee
    @philslinkee 2 года назад

    I can't get this architecture to work unless I generate classes for my entities (public class MyEntity: NSManagedObject { etc. etc.}). I'm guessing you did this but I missed it somehow?

  • @adrianomaiaoficial
    @adrianomaiaoficial 2 года назад

    Hi!! This class CoreDataViewModel... if i cut this and paste in another file. How can i use this on all my views, it's automatic?

  • @ben.aka.bigben
    @ben.aka.bigben 2 года назад

    Great tutorial but you never used model for your transactions. You could have created an instance of model on any CRUD operation and pass it to the VM instead of on the fly object from UI

  • @beejay1337
    @beejay1337 3 года назад

    Hi. Very nice intro to how CoreData works in conjunction with MVVM. I got two questions:
    1. Assuming CoreData container grows bigger and bigger with various entities and entries, is there any downside to performance when using this MVVM approach? Reason I'm asking is that now every time you change something, save etc. you run the full fetch request - not sure if the @FetchRequest maybe is any more efficient in that?
    2. How do you usually set up your ViewModels in a larger App? Do you create one big ViewModel? Multiple ones? Do you have any general approach to that?

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +1

      Hi Jakob, great questions.....

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +3

      1. Running the full fetch request can be performance intensive, but Core Data is very powerful and I don't think it would cause performance issues unless there was a very large data set. If you had a large data set, you would probably have a "predicate" (aka filter) on the FetchRequest so that you don't actually fetch ALL the data, but rather a subset. If you did want to improve performance, you could simply save to CoreData and then update the "savedEntities" array manually! The @FetchRequest is probably less efficient overall and not very practical for MVVM apps (or any architecture really).

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +3

      2. The architecture of any app is pretty unique to the app itself. But generally speaking, I would say every Screen could have it's own ViewModel. However, it multiple screens share the same data, they would probably use the same ViewModel.

  • @developerios6096
    @developerios6096 3 года назад

    Good video, i have a question: is the xcdatamodeld file necessary? Can you define your entities using plain code somehow, avoiding declaring all your entities there?

    • @MacEns
      @MacEns 3 года назад +2

      You can have Xcode generate a NSManagedObject class file from the xcdatamodeld and use those clases if you prefer to work with the code directly, but the data model makes it really easy to make quick changes and Xcode handles all the code changes for you.

    • @developerios6096
      @developerios6096 3 года назад

      @@MacEns Thank you, it s always good to know all the available options

  • @azharuddinkhan1865
    @azharuddinkhan1865 2 года назад

    Thanks

  • @gabrielrml
    @gabrielrml 3 года назад

    Hi Nick sorry to go on BUT when it comes to editing a fruit do we just delete it and make a new one. This cant be right so I ask again how does the editing bit work within the MVVM method? Cheers

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад

      Hi Gabriel, our Models are structs, which are based on values. If we change the underlying values, we have to mutate the struct. We can use either a "mutating" function or create a new struct like we do in the video!

    • @gabrielrml
      @gabrielrml 3 года назад

      @@SwiftfulThinking Hi Nick thank you - can't help thinking that would have been useful shown in the tutorial rather than assuming we want to update with an exclamation mark. The season I watch tutorials is because I don't know how and want to learn. I will try and find another resource. Thanks again

  • @khaledaldousari3997
    @khaledaldousari3997 3 года назад

    Thanks for the video, I'd love to know how to save images to Core Data

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +1

      Hi Khaled! You technically can save images to Core Data by first converting them into Binary Data and then saving that. However, it is generally not the recommended approach. I would recommend using the FileManager or an NSCache to persist images. I cover those in videos #26/27 of this series!

    • @dugrut1325
      @dugrut1325 2 года назад

      @@SwiftfulThinking back in the day in SQL, I stored a Passport photos converted to Binary for a national a Employee app I developed, that allowed many other apps which I also wrote could draw from. I also took most of the photos. haha. The day I retired I shut my brain to all that and learned more about home renovations and carpentry. I built two off the grid cabins [vaulted ceiling & loft, solar, water capture, sauna, hot shower] and now presently I'm working on a large addition to one of them that has a multi pitch hip roof, something new for me. On my nights and early morning hours I'm learning SwiftUI, thanks!

  • @dugrut1325
    @dugrut1325 2 года назад

    Odd thing. The list will update automatically when I add a new record but it will not refresh when I do an update. I know it is changing the data and saving the data, because went I start typing in the TextField and list refreshes with the update. Weird. I can not understand why this would happen?

    • @brianben1
      @brianben1 10 месяцев назад

      Had the same issue. I had This in the view
      @State var vm = CoreDataViewModel
      Needed to be
      @StateObject var vm = CoreDataViewModel

  • @Mahadev-x7u
    @Mahadev-x7u 3 года назад

    Thank you...

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад

      Andrej always staying up to date! Thanks for the support brotha

    • @Mahadev-x7u
      @Mahadev-x7u 3 года назад +1

      @@SwiftfulThinking Thank you... I always ... Now I finish with clone one app and jump to your course in Udemy. You go right way Nick... Thank you for sharing your knowledge .... I like your explanation, clear and different corners

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +1

      @@Mahadev-x7u thanks Andrej! FYI, I made that course a long time ago and I will be posting better courses on here in the next few weeks.

    • @Mahadev-x7u
      @Mahadev-x7u 3 года назад

      @@SwiftfulThinking very good.... Go Beyond

  • @relax_music668
    @relax_music668 Год назад

    How to reference it in other view files?

  • @samarghourab5545
    @samarghourab5545 2 года назад +1

    Thanks for this awesome video. Was all very clear but I seem to be having a bit of a brain block on one thing. In the func updateFruit(entity: FruitEntity) on line 49 it says entity.name = newName. Can't wrap my head around that. Doesn't the function need to be mutating to change entity.name from within the function. Hope someone can help me with this.

    • @SwiftfulThinking
      @SwiftfulThinking  2 года назад +2

      Mutating is for when you are updating an object that is based on Values (ie. a Struct). CoreData Entities, however, need to conform to NSObject, which require them to be Classes.. which are based on References. Therefore, we don’t need to “mutate” here. (I have an upcoming video on Structs vs Classes that will hopefully make this more clear)

    • @samarghourab5545
      @samarghourab5545 2 года назад

      @@SwiftfulThinking Got it! Thanks very much for the response!

  • @dugrut1325
    @dugrut1325 2 года назад

    it took me an hour to figure why nothing was working. line 35. I didn't realized you added the 'savedEntities = ' to the 'try container' line. Stupid me.

  • @krq999
    @krq999 Год назад

    My comments was deleted because of a link - I found a post on apple dev forums that says "Stop using MVVM for SwiftUI" and suggests encapsulating this logic inside of a view

    • @SwiftfulThinking
      @SwiftfulThinking  Год назад +1

      The examples in that post are for simple projects. Don’t listen to that nonsense 😅

  • @serhii_rs
    @serhii_rs 2 года назад

    String! Not Shtring!

  • @marct.1776
    @marct.1776 2 года назад

    funny