SwiftData Basics in 15 minutes

Поділитися
Вставка
  • Опубліковано 29 гру 2024

КОМЕНТАРІ • 142

  • @CodeWithChris
    @CodeWithChris  7 місяців тому +1

    👋 Our "Launch Your First App" program will help you build up your iOS skills to publish your very own feature rich app even if you’re a beginner starting from scratch. cwc.to/youtubeoffer

  • @danuff
    @danuff Рік тому +10

    Simple, and to the point. Thank you!

  • @thetutorialdoctor
    @thetutorialdoctor Рік тому +4

    Excellent short yet complete tutorial on how to create a swift ui CRUD app. Appreciate this.

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Glad it was helpful! Thanks for learning with us! - Iñaki

  • @andriybelizky9318
    @andriybelizky9318 Рік тому +4

    Awesome Video, I appreciate simplicity of examples.

  • @karlostj4683
    @karlostj4683 11 місяців тому +1

    Great job! Thanks for the basics, which is what everyone should start with!

  • @BasicInsideOut
    @BasicInsideOut Рік тому +4

    Really good and simple description, especially for the CRUD operations.

  • @rjamil
    @rjamil Місяць тому

    Great video. Straight to the point.

  • @primalcam812
    @primalcam812 3 місяці тому

    Thank you for keeping the code short and to-the-point :)

  • @RiccardoAlfano317
    @RiccardoAlfano317 Рік тому +1

    Great video I just started with swif but I’m pretty secure that I’ll learn Alot with your UA-cam video Italia Grazie

  • @Ward1982
    @Ward1982 7 місяців тому +1

    Brilliant. Chris you're great.

  • @daxuan90
    @daxuan90 11 місяців тому +1

    Your tutorial is clear and easy understand. Thank you! ❤

  • @eman31683
    @eman31683 Рік тому +2

    Wow that is a lot easier than CoreData directly.. Good video Chris and thank you for your time!

  • @KiTO키토
    @KiTO키토 7 місяців тому +1

    this is the best swiftdata tutorial!!! thank you!!

    • @CodeWithChris
      @CodeWithChris  7 місяців тому

      Glad it was helpful! Thanks for watching! - Iñaki

  • @mr._vico
    @mr._vico 3 місяці тому

    10:35 I think that this delete method is simpler and fancier, but I think your method is more trusty
    .swipeActions(edge: .trailing) {
    Button("Delete", systemImage: "trash", role: .destructive) {
    context.delete(item)
    }
    }

  • @Alexander060444
    @Alexander060444 2 місяці тому

    good video appreciate the effort.

  • @jangelGuerrero
    @jangelGuerrero Рік тому

    Amazing, I love this example, I have all to use it, thanks you and success in everything you do, greeting from México City.

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Glad it was helpful! Thanks for learning with us! - Iñaki

  • @tonyhawk123
    @tonyhawk123 Рік тому +1

    Nice clear presentation style. Cheers!

  • @bklock7
    @bklock7 2 місяці тому +1

    Why doesn't the view update whenever an item is added to the context?

  • @lvterry
    @lvterry 5 місяців тому

    clear and straightforward. great tutorial 👍

  • @kaato33
    @kaato33 10 місяців тому

    Thank you! I was scared to approach this topic but you made it easy to understand!

    • @CodeWithChris
      @CodeWithChris  10 місяців тому

      Hello! We're glad you found your video valuable! And thank you for the appreciation. :)
      --Joash

  • @AkimboFennec
    @AkimboFennec 4 місяці тому

    Hey Chris, I have a question for you. After watching wwdc 2024, i see that swift data now supports more operations, like history tracking and custom model configuration implementation. Would you say that SwiftData is now ready to be used? Also, did they resolve a bug, when you decorated your model with @Attribute(unique) that the app crashed ?

  • @bobmcnerney1
    @bobmcnerney1 11 місяців тому

    Very easy tutorial to follow. Thanks!!

    • @CodeWithChris
      @CodeWithChris  11 місяців тому

      Glad it was helpful! Thanks for watching! - Iñaki

  • @sk4tec
    @sk4tec 6 місяців тому

    Ahh - feels like I'm back home again witha CodeWithChris video!

  • @rapier64
    @rapier64 Рік тому +1

    Thanks for this very good tutorial!!!🙂

    • @CodeWithChris
      @CodeWithChris  Рік тому +1

      Glad it was helpful! Thanks for watching! - Iñaki

  • @helena9210
    @helena9210 Рік тому +1

    Thanks!!! Fast focused and clear

  • @penyt
    @penyt Рік тому +1

    Just wondering, if we follow MVVM, can we put that @Environment context in the ViewModel class?

    • @penyt
      @penyt Рік тому +1

      I've read up quite a few information since, I feel like with SwiftData MVVM seems less relevant and it might become more complicated if we strictly want to implement MVVM.

  • @wanderer1357
    @wanderer1357 Рік тому +1

    Great video. Much easier than Core Data!

  • @virendragupta5945
    @virendragupta5945 Рік тому

    Great Demo Chris ....Lot easier than earlier database access !!! ... Thanks :D

  • @vincent2700
    @vincent2700 Рік тому

    Thanks for the introduction on this

  • @anhalexdinh2190
    @anhalexdinh2190 10 місяців тому

    very great tutorial for basic concept

  • @maryannadelman4438
    @maryannadelman4438 Рік тому +1

    I have a core data app that I’ll be changing to swift data after seeing this. Question: in my app now, I can click a button in one view that will add item to core, then when I go to view that has the list it will be there. I’m assuming this will be easy to do in swift data also? Not sure how I’ll do that though.

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Hello @maryannadelman4438!
      To be honest I'm not sure how to answer your question, maybe our community members can help. You can share this to our community forum @ [codecrew.codewithchris.com/]
      --Joash

  • @divsyntax9720
    @divsyntax9720 6 місяців тому

    Haahahhahahahahahah when u were searching for the icon, I CAN RELATE!!! 😂 Awesome tut btw!

  • @neila880
    @neila880 Рік тому

    Thanks for the video. SwiftData looks really nice!!

  • @trevor-
    @trevor- 4 місяці тому

    What was that app you pulled up that had a list of all the symbols and associated names?

  • @sirflimflam
    @sirflimflam Рік тому

    I find it kinda funny I was asking "why the underscore on the parameter name?" as you kinda just glazed over it in the delete function and I HAD TO KNOW so I went and looked it up. Then a bit later you explain it for the update function.. I SHOULD HAVE TRUSTED YOU GOOD SIR.
    SwiftData is pretty awesome though. I'm...struggling to get a good grasp on Swift. I've been doing C and C# for much of my life and something about Swift just throws me off. But your channel has at least put me in the right path.

  • @yourbestsail
    @yourbestsail Рік тому +1

    Excellent teaching skills 😊

  • @ameliasaomarcos
    @ameliasaomarcos Рік тому

    I do it now, with your tutorial. thanks.

  • @The1tjc
    @The1tjc Рік тому +5

    Fyi, this is not showing up in UA-cam under your videos, nor did it pop up in my feed. I discovered it from your twitter post.

    • @CodeWithChris
      @CodeWithChris  Рік тому +3

      Our Twitter post was a bit... prematured! Oopsy!
      @AdrienVillez

  • @ruggedd3signz
    @ruggedd3signz 11 місяців тому

    I am getting an error at part 8:07 "Missing argument for parameter 'id' in call" I'm using Xcode 15.0 and iOS 17. Can you explain what I am missing as I am new to swift and swiftdata.

    • @ruggedd3signz
      @ruggedd3signz 11 місяців тому

      I was able to figure out the issue with the addItem module had to use *let item = DataItem(id: UUID().uuidString, name: "Test Item")* after that everything else was smooth sailing. Great tutorial on SwiftData. Subscribed and can't wait to watch more videos. Thanks

  • @mario_luis_dev
    @mario_luis_dev Рік тому +1

    great demo Chris, really liked the way you explained it. New sub here :)

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Awesome, thank you and happy learning!
      --Joash

  • @antonreashin
    @antonreashin Рік тому

    thanks, I'm just going to use this in my project🙏

  • @jeffnosanov5761
    @jeffnosanov5761 4 місяці тому

    I see that this is about how to store list items on local storage, but how does one store simple variables such as an int?

  • @JenniferHolub-g2x
    @JenniferHolub-g2x Рік тому

    Love Your videos!! I have started a project in SwiftData, but I can not get the @Query to filter on date?? I've checked all the forums, and many people seem to be struggling, but no real answers that work for me. Any advice on filtering on date in SwiftData??

  • @paininmydroid4526
    @paininmydroid4526 4 місяці тому

    This looks real easy.

  • @Pedro76mchlkg
    @Pedro76mchlkg Рік тому

    Thank you very much. I have a question, if I add a variable to the model, will it break the model?

  • @thompsonms9941
    @thompsonms9941 Рік тому

    Good one bro , Thanks !

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Thanks for watching, and thanks for learning with us! - Iñaki

  • @nil_at
    @nil_at Рік тому

    Is there some kind of visual view integrated to Xcode to see the current database layout, entities, relations, and data and so on? Like pgAdmin for Postgres for example?

  • @LebenWerden
    @LebenWerden 7 місяців тому

    Hi, how I can use onMove modifier on Query?

  • @prems1331
    @prems1331 Рік тому

    Wonderful Video. Love it ♥

  • @sabata657
    @sabata657 8 місяців тому

    so good video my bro

  • @ElantraMan
    @ElantraMan 11 місяців тому

    How would this work using the likes of a view model?

  • @chezchezchezchez
    @chezchezchezchez Рік тому

    Brand new to Mac development.
    Never used coredata.
    Where can I find the rest of the tutorial that explains things like… how .onDelete creates these magical indexies , and why they swipe view shows up without any code, showing anything about swiping etc. thanks!

  • @benjaminfaershtein138
    @benjaminfaershtein138 Рік тому

    Hey I just started watching your videos and I was intrested your collection of keyboards that are always prominent in your videos. Would be cool to see a video talking about your keyboards or a setup tour.

  • @Hendrik6
    @Hendrik6 Рік тому

    Nice explanation, thanks a lot 😊

  • @kailasvilaskore
    @kailasvilaskore 4 місяці тому

    How can I connect to AWS Amplify Datastore using SwiftData ?

  • @Tritoon710
    @Tritoon710 6 місяців тому

    Is it like an embedded database? can you sync data from SwiftData to an online database like MongoDB Atlas?

    • @CodeWithChris
      @CodeWithChris  6 місяців тому +1

      No, SwiftData is not an embedded database, it's an object graph and persistence framework, more like an ORM. It uses SQLite as one of its persistent store.
      You can sync data from SwiftData and MongoDB Atlas but it requires extra and redundant work, I wouldn't recommend it.
      SwiftData comes with built-in support for iCloud syncing. If you need to sync data from your app to Mongo Atlas DB, I recommend using Mongo Realm instead of SwiftData (www.mongodb.com/docs/atlas/device-sdks/sdk/swift/). - Iñaki

    • @Tritoon710
      @Tritoon710 6 місяців тому

      @@CodeWithChris Many thanks for the detailed answer 🙏🏻

  • @amith89rm
    @amith89rm Рік тому +1

    Why is everyone stuck with todo program? There are like millions of example online for todo program. Why not do user login and register and delete user using swiftdata. But thank you for this amazing tutorial.

  • @pnkbrn
    @pnkbrn Рік тому

    Thanks!
    Would love to see a video on sorting and filtering Query data.

  • @hassanportal5865
    @hassanportal5865 Рік тому

    Hey Chris do you know if Firebase can work with visionOS. It seems there’s only the options for iOS not for anything else

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Hello @hassanportal5865
      Unfortunately I'm not sure about the answer.
      --Joash

  • @vanylaskywalker
    @vanylaskywalker Рік тому

    Should we still use codable structs to decode JSON API responses or should we use the new codable @Model class to decode API responses? Which is better?

    • @CodeWithChris
      @CodeWithChris  Рік тому +2

      You can actually do both, but if you add the Codable conformance to your SwiftData model, you'll have to manually write the Decodable and Encodable conformances yourself, as derived conformance simply doesn't work out the box.
      @Model is a Swift Macro, and it adds boilerplate code that does not conform to Codable (that's why derived conformance doesn't work).
      Donny Wals has written a great article about it, you may want to read about it here:
      www.donnywals.com/making-your-swiftdata-models-codable/
      Have a good day! - Iñaki

    • @OoohYeahhByKlausi
      @OoohYeahhByKlausi Рік тому

      @CodeWithChris Hey Chris, as soon as i typ in: "@Model", there comes a red message saying: "@Model requires an initializer be provided for 'DataItem". Please help. What did I do wrong?

  • @JustYe322
    @JustYe322 Рік тому

    Can you get XCode on MacBooks too, or just the desktop?

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Hi @JustYe322,
      Yes! Xcode run on any mac.
      You can also check this link to see the minimum system requirements to be sure that your machine can working on the latest version available.
      developer.apple.com/support/xcode/
      Hope this help.
      --Joash

  • @Hshshsusuu62627
    @Hshshsusuu62627 8 місяців тому

    At 8:00 when I tap I get a Preview Error message. HELP!!!!!!!

    • @CodeWithChris
      @CodeWithChris  8 місяців тому

      Hi, in the video Chris ran the app in the Simulator instead of using the SwiftUI preview.
      There is an additional code setup required to make the SwiftUI preview work with SwiftData, but it doesn't simulate any persistence functionality that you might expect.
      To run the app similar to the video, make sure to select a Simulator as your destination (on the top middle part of Xcode), then press Cmd + R. Xcode should build the project and launch the app in the iOS Simulator you chose.
      Hope that helps! - Iñaki

  • @peetorres
    @peetorres Рік тому

    It will have support for CloudKit?

    • @CodeWithChris
      @CodeWithChris  Рік тому

      "To provide automatic iCloud sync, SwiftData requires the CloudKit entitlement and an iCloud container. For more information, see Configuring iCloud services."
      For more information, you can check out: developer.apple.com/documentation/swiftdata
      Thanks for watching! - Iñaki

  • @blackookami5621
    @blackookami5621 Рік тому

    that was really cool. thx

  • @michaellittle1665
    @michaellittle1665 Рік тому +1

    Thank you Chris that is good, I'm going to be undertaking in my second semester as part of my masters in IT the unit in iPhone software engineering. I hope they are up-to-date as you are!

  • @geoffstokeld4015
    @geoffstokeld4015 Рік тому

    Do you still need Identifiable protocol? Really good video thank you.
    From another tutorial
    ‘SwiftData automatically handles the identification aspect of the model, eliminating the need for explicitly defining an id property or conforming to the Identifiable protocol.’

    • @w0mblemania
      @w0mblemania Рік тому +1

      I'd still add a UUID (not a String).
      That way, it allows you to separate out distinct models instances, even if they happen to share the same data.
      It would be better for your own sanity, and debugging.

  • @ameliasaomarcos
    @ameliasaomarcos Рік тому

    Nice.!!!

  • @jr_fin
    @jr_fin Рік тому

    Hey! When I query my database and try to insert the variables like name, it throws up an error saying "Value of type '[my class]' has no member 'name'". Is there something simple I'm missing?

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Hi! Sorry you're running into that!
      Have you checked if there is a `name` property in your data model class?
      You can declare it like how Chris did it on this timestamp: ua-cam.com/video/krRkm8w22A8/v-deo.html
      Hope that helps!
      - Iñaki

  • @pnkbrn
    @pnkbrn Рік тому

    Can you use this in a MacOS application?

    • @CodeWithChris
      @CodeWithChris  Рік тому +1

      Hello @Kyriacos-ue5kt,
      Indeed, you can utilize the new SwiftData API across all Apple development environments. It's not exclusively limited to iOS.
      --Joash

  • @pedrojosemoragallegos
    @pedrojosemoragallegos Рік тому

    In more complex applications we usually use different design patterns like the repository pattern and try to move away the functions from the view itself. How would you implement a repository pattern etc. with the SwiftData? :)

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Hello,
      Unfortunately, we can't answer you in the comment section but you can try joining and posting in our community: cwc.to/codecrew
      -- Joash

  • @DesarrolladorSwift
    @DesarrolladorSwift 10 місяців тому

    Excelente

  • @chickenrei3876
    @chickenrei3876 Рік тому

    Hi Chris, can you make a video on how to write neat swiftui and code that can be read by other developers?

    • @MikaelaCaron
      @MikaelaCaron Рік тому

      I made a video on this, but it's not specific to SwiftUI, but how to write good Swift code in general ua-cam.com/video/4hVyozTOSTo/v-deo.htmlsi=K8ORdCwzcDNpFPB9

  • @ritzg98
    @ritzg98 Рік тому

    I get a Preview Crashed error when I try to add a record to the model. Does anyone know why that would happen?
    I'm pretty sure the code looks the same as Chris's code.

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Does it show any error in the console log? If it does, you may wanna post about it in our developer community forum: cwc.to/codecrew
      Someone might be able to help see what's wrong with your code or be able to determine what caused the issue. - Iñaki

  • @adarshgadepalli4847
    @adarshgadepalli4847 Рік тому

    hey chris im currently a new app dev, can data be stored in firebase as well as locally with swiftdata synchronously?

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Firestore has a local data persistence feature, so you no longer need SwiftData to persist the data that you store in Firestore. - Iñaki

  • @VladislavVaz
    @VladislavVaz Рік тому

    can someone help me please ..
    i have a SWIFTUI application with a flow as follows: A(landscape orientation)->B(landscape)-C(portrait)->D(portrait). also when I navigate back from C to B it should turn back to landscape as B is in landscape. (I am using NavigationLink in my application to navigate)How do I achieve the portrait lock in swiftUI.
    i tried the .onAppear{} and .onDisappear{} method.. (firstly it is no longer available on ios 16 and secondly it gives a choppy animation where the view does not expand fully to take the new rotated screen size; there is white space after it rotates)

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Hello, @VladislavVaz!
      Unfortunately we can't debug it for you in the comment section here but you can try joining and posting in our community: cwc.to/codecrew
      --Joash

  • @DefeatOG
    @DefeatOG Рік тому

    I keep getting a 0__abort_with_payload error and I've not found anything online that fixes it. Any idea? Thanks for the video!

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Hello, @DefeatOG!
      Unfortunately we can't debug it for you in the comment section here but you can try joining and posting in our community: cwc.to/codecrew
      --Joash

  • @littlebrotha123
    @littlebrotha123 Рік тому

    wow! so much better than the coreData workflow.
    So will swift data ever be compatible with older iOS versions or will it only ever be compatible for iOS17 and up?
    I can't wait until this becomes the standard and we can shove coreData into the abyss. but if it's only ever going to be compatible for iOS17 and above then it's going to take some years right?

    • @littlebrotha123
      @littlebrotha123 Рік тому

      also, Chris - your teaching style is world class. You have the advantage of having a very easy voice to listen to.
      I really do hope you make a "100 Days of Chris UI" or something in the future

  • @jmacutube991
    @jmacutube991 10 місяців тому

    When i type in line 29 i get error "Cannot find 'context in scope'. rest of code exactly as you typed it in? strange

    • @CodeWithChris
      @CodeWithChris  10 місяців тому

      Hello,
      Unfortunately, we can't debug it for you in the comment section here but you can try joining and posting in our community: cwc.to/codecrew
      --Joash

  • @napoleontsar
    @napoleontsar Рік тому

    Until now I don't understand how to create a button that you can click on for moving to another view page in the app..

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Hello,@napoleontsar! You may want to check this video to learn more about NavigationStack. ua-cam.com/video/7dnTHrLyFLc/v-deo.html&ab_channel=CodeWithChris
      --Joash

  • @Kai-wu5hd
    @Kai-wu5hd Рік тому

    Can SwiftData work on iOS 15 and above , bro?

    • @CodeWithChris
      @CodeWithChris  Рік тому

      No, SwiftData is supported in iOS 17+. You'll still have to work with CoreData if you need to support iOS 16 below. - Iñaki

  • @event-subscriber
    @event-subscriber Рік тому +1

    Similar to useState in react native🤔

    • @w0mblemania
      @w0mblemania Рік тому

      Except, actually native. And your app will feel like a real iOS app.

  • @carolinetakamhere
    @carolinetakamhere Рік тому

    how would you use AI to automate this building process?

    • @CodeWithChris
      @CodeWithChris  Рік тому +1

      Unfortunately I'm not sure about the answer, @carolinetakam2677.
      --Joash

  • @ho6y
    @ho6y Рік тому

    Absolutely well explained, really simple compared to CoreData

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Glad you like it! Thanks for watching! - Iñaki

  • @babida9113
    @babida9113 Рік тому

    For some reason my Xcode crashes after clicking add items.

    • @CodeWithChris
      @CodeWithChris  Рік тому

      Hello @babida9113!
      Unfortunately we can't debug it for you in the comment section here but you can try joining and posting in our community: cwc.to/codecrew

    • @dylan1401
      @dylan1401 Рік тому

      I had the same problem, were you able to find a solution?

  • @mr.spokesman5849
    @mr.spokesman5849 6 місяців тому

    Darn ... too bad this is unusable while working with MVVM, I tried today to somehow bend it to my will ... guess what ... went to core data after ready long struggle.

  • @levous2
    @levous2 11 місяців тому

    Nice work on separating behavior from view. Too few examples take the care to demonstrate clean code. You, sir, have saved many headaches by teaching good practices

    • @CodeWithChris
      @CodeWithChris  11 місяців тому

      Glad you found it helpful! Thanks for learning with us! - Iñaki

  • @First.Last.99
    @First.Last.99 5 місяців тому

    Not a word about what if user changes his phone.

  • @REVOLSAMI
    @REVOLSAMI Рік тому

    you misled people by using the swiftlet icon. shouldnt have used it. i was looking for swiftlets video. shame.

  • @fdurmaz
    @fdurmaz Рік тому

    Thank you @CodeWithChris

  • @AkimboFennec
    @AkimboFennec 4 місяці тому

    Hey Chris, I have a question for you. After watching wwdc 2024, i see that swift data now supports more operations, like history tracking and custom model configuration implementation. Would you say that SwiftData is now ready to be used? Also, did they resolve a bug, when you decorated your model with @Attribute(unique) that the app crashed ?