iOS 13 Swift Tutorial: SwiftUI and Core Data - Build a To-Do List App
HTML-код
- Опубликовано: 15 сен 2024
- Learn how to bring together Core Data (data persistence framework from Apple) and SwiftUI by building a simple To-Do list app from scratch.
➡️ Tutorial Files: / xcode-project-to-29153940
➡️ Related Tutorials:
Understand SwiftUI: • iOS 13 Swift Tutorial:...
Core Data: • iOS Swift Tutorial: Ge...
🛒 GAME DEVELOPMENT COURSE - JUST $20 🛒
www.udemy.com/...
👏 Support me on Patreon: / brianadvent
➡️ Web: www.brianadvent...
✉️ COMMENTS ✉️
If you have questions about the video or Cocoa programming, please comment below.
#swiftui #swiftlang #iosdev
There's a plethora of SwiftUI how-to videos and sites, the bulk of which are incomplete, wrong, or poorly made presenting half-baked solutions. Brian's videos are thorough with a great amount of knowledge shared. Thanks Brian!
true
Rock Solid, thanks! Actually a lot of the code you write, now comes default in Xcode 12
Great tutorial thank you! I'd love to see an advanced tutorial on core data where you deal with many-to-many relationships, update data and query only a subset of items from the core data.
Please, I have looked everywhere on how to properly change NavigationView/List background Color in SwiftUI, Thanks to Brain for another wonderful tutorial.
22:47 This is a Great tutorial and if u had the same problem as me here I found the solution
The problem was that my ForEach was working and display as many rows as elements in my CoreData Model, but each label was set with the first element.name .
So the values were there but the loop didn't iterate properly.
The solution is that in the example above, you need to change "ForEach(self.toDoItems)" to " ForEach(self.toDoItems, id: \.self)".
IIwasn't required at the time the video was recorded or it might be that my structure requires it.
Nevertheless this tutorial is still one of the most complete on the topic and if you found my same problem, hope my comment can help you! much love people
Hey Brian, thanks for this video.
This tutorial is crazy useful.
But I need some help.
In my use case, I have to put the TextField below the ForEach (Just switch the places of TextField and ForEach).
Now, whenever we add a new ToDo item, the TextField goes down (Just like Apple’s Reminders app).
If the app has many toDo items, the keyboard covers the TextField when the keyboard appears and we can’t see the TextField.
What I want to know is how to automatically scroll the List ( move the view up) to see the TextField when keyboard appears.
Please help me.
Thanks for reading my long comment. Have a great day.
YOU ARE MY CHAMP. I did not have a chance yet, but I will be viewing it this week
I already do like above, but my simulator just display a blank screen?
Strange. I get the error:
Value of type 'NSManagedObject' has no member 'createdAt'
Value of type 'NSManagedObject' has no member 'title'
On the "ToDoItemView" line in the ForEach loop. Any ideas? The add button works, and the number of to-do's increases, but that one piece isn't working.
I have the same issue
Same here. macOS 10.14.6, Xcode 11.0 (11A420a)
Saaammmeeeee
stackoverflow.com/questions/59061270/swiftui-foreach-of-fetchedresults-gives-the-error-value-of-type-nsmanagedob
CoreData in SwiftUI tutoríal : ruclips.net/video/X2qeZj0Xzrs/видео.html
Xcode 11.5 - it is not necessary to modify SceneDelegate.swift, context and contextView are defined.
If you are bothering with the dysfunctional preview, see stackoverflow.com/questions/59514875/swiftui-coredata-crashes-preview .
If you want to use the folding ability of Xcode: Menu - Editor - Code Folding - Fold, and there you also find the keyboard shortcuts
Foremost, THX!
Having a reference of the model inside the ContentView (controller) is not agains a clean architecture?
I am so confused. My code looks exactly the same to yours but on line 43, I’m getting an error saying ‘Font’ is not convertible to ‘Font?’
Same problem here...
@@praetoriancze Update** Watching the video a fourth time I noticed I'm using an updated version of Xcode 11.3.1, and it adds extra code in the SceneDelegate.swift. I'm still researching what effect this would have on the code** I've run into the same issue, I haven't been able to find the solution yet unfortunately :(
Excellent video, a very well done tutorial. Had to pause a few times to let stuff sink in, but that’s my brains limitation, not a fault of yours :). SwiftUI looks to be pretty powerful, and the more I learn about core data the more I like it.
Thx for this amazing tutorial. Would Love to See an App which is communicating with the Apple Watch, maybe as an Extension on this App. Keep up the good work.
Very good tutorial and I like the way you use this extension for the FetchRequest 👍🏼 One question though, I did some trainings on Core Data and on fetching and decoding JSON data now but I love to see an tutorial on fetching JSON and storing it in Core Data (preverably with more then one entity with a relation). Do you have such a tutorial or plan to make one in the near future? In any case, thanks again man! Very clear tutorial
Cool stuff. Thanks Brian.
I think I understood how to add and delete an item. But how to modify an item, e.g. in the same view which I use for adding items? I cannot realize a cancel button to abort the modifications I already typed into the field. Any help for me? Rgds, Martin
Do more more more Swift UI tutorials!!!!!
Very nice tutorial.
Saves me a lot of work to make the app working :)
Keep up the good work :)
your tutorial is really great. I tried your To-Do List App with Core Data, it works very well. But then I tried to work with Core Data using the cloud kit. I just marked the Core Data in Cloud Check (creating the App). Now I have the problem the App will not work, because there is a crash in beginning the app. I get a signal SIGABRT in the second line of ContentView (the line with @FetchRequest(fetchRequest ...) Is there anything else to change to store the data in the cloud?
having this issue too
stackoverflow.com/questions/62676987/could-not-cast-value-of-type-swift-optionalswift-anyobject-to-nsfetchreques found this on stackoverflow. You have to add @objc(ToDoItem) above the class declaration of ToDoItem
@@Nik6644 Genius!
@@Nik6644 bro you saved my life
I don't have the same file system you do, so it is impossible to proceed. I think it is good idea to mention which Xcode Version you using. I am using Xcode version 12.4.
Really awesome video made for core data along with swift UI
Thank you thank you for explaining what you were doing while you were doing it ! Thank you
hey brain, thank you for your tutorial its substantially helpful. i have a problem here with the app, so it keeps crashing for this reason" could not cast value of type 'Swift.Optional' (0x7fff89e42578) to 'NSFetchRequest' (0x7fff89e42618)". i tried to lookup solution or updates but couldnt find any! help me please.
This might help stackoverflow.com/questions/53690712/no-nsentitydescriptions-in-any-model-claim-the-nsmanagedobject-subclass
any github repo to see the code?
Great stuff!! I like it and helped me a lot to get a quick understanding. Is the preview crash fixed (after adding the fetch request)? Would be great to see it in the preview together with coredata!
IDK why this is happening, but when I add a new task, unlike your video, the new row is being added upper the previous row, not beneath the last row.
I have been keeping watching this video again and again what mistake I made, but still can't find it...
Can someone drop me an idea or words that might be causing this error? Thanks;)
How would you implement the EditButton() for a UITableViewController? I can't find any documentation on that, so if you could help out it would be really apprecited! Keep up the great videos
Do you have any tutorial for storing a simple file on iCloud Drive folder using filemanager
Thank you Brian for another amazing tutorial🙏
Hey I was trying to make this into a tab in one of my tabbed views but I don’t know what I have to change I the root hosting to do that
Love it keep up the good work Brian.
You had me... until you wrote that "ToDoItem" function, Jesus. Things like that intimidate me and make me question if I'm even smart enough for this.
Either way, great video and everything was definitely well explained - I just need to learn a little more Swift / Xcode before biting off more than I can chew I think, lol.
Hey Karsen, you are definitely smart enough and absolutely right. If you are a beginner, CoreData can be a little bit intimidating because of all the new terms and concepts that you need to deal with. But keep pushing and you’ll get that hang of it!
This is an excellent video. Very helpful.
I got that error yesterday after implementing an environment object to my view. the way I fixed it was passing an environment object to the preview. Maybe if you pass a nsmanagedobject the canvas will work..?
This is really cool. U r so brilliant. I think this is the big help to know about CoreData and SwiftUI. I appreciate it. Ive been waiting to watch ur brand new tutorials. 🤗🤗🤗
If you want to change an item in the ToDoItemView (lets say the title), it is not reflected in the UI. Even though it is stored in CoreData. You have to somehow bind the toDoItem in order to see the changes. How would you do that?
Great job! Thank you!
Well content with cool explanation, thanks bro
Hi Brian, really appreciate the video. I'm not used to the view having direct access to a database service (context). Not sure what a good structure is for SwiftUI apps. I'm currently trying to use a MVVM structure.
Brian thank you for the video.One question why do you have to put .navigationBarTitle on the curly braces of the list instead of the last curly braces of the navigationview that's where makes more sense since the title is to be set to the navigation view and not the list? thank you
what is the difference between a view controller and a content view I am confused if I have to use a content view instead?
Hi Brian,
Thank you for the tutorial. I was wondering if you could update your "Complex SwiftUI" tutorial for Xcode beta 5. It became broken in beta 3. I have been trying to fix it for the last few weeks but I am new to this and I can't figure it out.
Man, thank you so much! You are very very appreciated my brother. Much love
Awesome video, short and to the point -- thank you! One question: Is there a particular reason why you embeded the VStack of the title and createdAt Texts for the ToDoItemView inside of a HStack?
Brian -- can you also show how to do this using a ViewModel architecture?
As I was building this by myself, I encountered a problem. With Core Data, everything works fine. But how can I add a WebRequest with the URL Session to this project?
Maybe you could help me archieve this withhin the already existing "FetchedResults" and "Fetchrequest".
Best regards
In creating the ToDoItem.swift file, I get plenty of errors stating that it is a redeclaration of the class. I found that adding the data model to core data, it creates this class with this name. So I guess we dont need to do that? Only thing is, I can't create the extension. not sure why. If I comment out the class and just add the extension, I get the message that I am using an ambiguous use of fetchRequest().. UGH
If I dont, however, use the same entity name, all seems OK..
Question: Why is het unsafe to unwrap the title en createdAt when showing it in de section with ToDoItemView.
Hope you understand what i mean.
Thanks for the tutorial!
hey ... random question ... how can you make a clone of notion or taskade.com ?
Hi Brian, thanks for your amazing tutorials! I used your video(s) as a guide to set up a very basic watchOS 6 application with Core Data support. However, I ran into very weird issues, like I'm unable to set the managedObjectContext once at the ContentView level (inside ExtensionDelegate), and then use it later on in sub views (Context in environment is not connected to a persistent store coordinator).
Would highly appreciate any advice. Thanks!
Cool that can delete. But can’t mark as done (strike and another color)
Very good, thanks a lot!
great thanks you, how you think when all will start use swiftui?
I will use it today. But I recommend to use it only if you don't need backwards compatibility and have fun fixing a lot of bugs and changes over the years. But useable is it right now (kind of you need to mix it with UIKit). If you don't want to use it today I think you should wait 1-2 years
How to add a max length for a UITEXT FIELD in SWIFT UI (i mean in this course)?
how do we use previews when using core data?? im baffled 🤪
Cool as always! Thank you
greatly appreciated 🙏 🙏
Thanks for the great tutorial! :D
How does this fit the MVVM pattern?
Your tutorials a very good and I really appreciate them however it's really annoying that sometimes I got to pause the video and zoom the page so I could see what you are writing or choosing, would be really awesome if could sometimes zoom when writing code or in general just make it a bit more zoomed like you. Thx anyway :)
When following along, at 5:15 when defining a new public class, users get an 'Invalid Redeclaration' error. You skipped all explanation of how and why we are avoiding a redeclaration here. Many other examples of shallow and useless explanations. The video description begins with "Learn how to..." For a user wanting an actual tutorial to understand and not just be shown, this video falls short.
Thanks for this guide, can you insert one with the integration of a search bar to filter the data in Core Data?
You will need UIViewRepresantable for that
I would like to completely eliminate the dependencies on UiKit :(
I try with: ForEach(users.filter { self.serchedText == "" ? true : $0.name.localizedCaseInsensitiveCompare(self.serchedText) }, id: \.self) { user in... but gives me an error
@@sermedix Unfortunately there are some UIKit elements that one will have to use in a SwiftUI project, but I'm sure the SwiftUI team is working hared on bringing us into the future, where all things will be made with SwiftUI magic 🧙♂️
The tutorial is wonderful! Very easy to follow. Thanks!
Thank you very much 👍
Thanks for your useful tutorial. Could you add some example how to use onMove handler with new Core Data feature?
stackoverflow.com/questions/57426250/modifying-a-fetchrequest
@@robertdesaegercto3043 I'd like to see code that changes the order of items.
I'm new to coding and when follow your tutorial the app crashes when i try to delete an object. I went over it many times and get the same result. Maybe I'm missing something?
Please provide the steps that let to the crash and the actual log of the crash from the console. If it's too long than you should try posting it on stackoverflow
Hi Brian, great video by the way. I have a question. I am creating an app that can save passwords, but I don’t want to use Firebase. what it does it saves the passwords on the iPhone. Would Apple allow this?
Thanks,
Amez
That seems like a horrible idea. Can't you use keychain?
Ben Mitchell I dont want to use anything thats on the icloud or online
Apple would not allow this unless it was encrypted. Even then, they probably still wouldn't let it in the App Store. Use it for personal use
Ben Mitchell so basically what I have is an app that you need a password to enter to access a text doc to add your passwords
I'm getting a "Failed to call designated initializer on NSManagedObject" warning.
OOh, how do you do that foldy thing? Ive googled foldy thing and got nothing, confused the hell out of me when you did it!
Click on the editor menu and go to code folding, Or press "option + command + left arrow key to fold" and right arrow key to unfold
James my guy! thanks buddy
Can you do a tutorial on Bluetooth with SwiftUI?
Does anybody know how to create a countdown app using swiftUI?
It's pretty easy. Contact me to show you how.
Rebeloper - Rebel Developer how would you like me to contact you?
TextField("ааа", text: self.$newToDoItem)
Type of expression is ambiguous without more context
Any thoughts?
CoreData in SwiftUI tutoríal : ruclips.net/video/X2qeZj0Xzrs/видео.html
Nice tutorial, could you explain what the scene delegate file is for ?
Video starts at 1:50
Nice, but... please bump up the font or reduce the resolution.
I'm sure if you redo this tutorial following your video you will discover errors in cutting the video because the code is missing
19:39 how you did it?
You need to enable it in preferences
CoreData in SwiftUI tutoríal : ruclips.net/video/X2qeZj0Xzrs/видео.html
Well it is basically not a tutorial.
No apostrophe in To-Dos, shouldn't be "ToDo's"; however, "Whats Next" should be "What's Next" ;)
🎊✌🏻️ 1st
Dude you are just showing but not explaining what is what...
CoreData in SwiftUI tutoríal : ruclips.net/video/X2qeZj0Xzrs/видео.html
what is the difference between a view controller and a content view I am confused if I have to use a content view instead?
Great job! Thank you