Easily Add Filtering In SwiftData Using Searchable 🕵🏾‍♂️ | Filter in SwiftData | #3

  Рет қаралды 4,094

tundsdev

tundsdev

Күн бұрын

Пікірлер: 46
@samuelhcohen
@samuelhcohen 11 ай бұрын
Watched a few tutorials before I found this one. None of them clicked until this! Thank you, my friend!
@nileshjdarji
@nileshjdarji 2 ай бұрын
I am extremely enjoying your this series. Great Job. I learned some cool stuff.
@andres121231
@andres121231 6 ай бұрын
You came in clutch many times ever since i started making my app a few weeks ago. Always had a video for whatever frustrating roadblock i was in. Really appreciate you sharing what you learned with everyone else, I could not fathom having to spend hours figuring this out on my own just by reading documentation. Thanks.
@tundsdev
@tundsdev 6 ай бұрын
Great to hear you found this useful, I’d actually check out my newer video with improvements on how to filter data too 👌🏾 A Better Way To Add Dynamic Filtering In SwiftData | SwiftData Tutorial | #16 kzbin.info/www/bejne/jGXOeXSBoqhoabs
@LG-ve9us
@LG-ve9us 6 ай бұрын
very good video, well explained and worked perfectly for my application... keep up the great work!
@tundsdev
@tundsdev 6 ай бұрын
Glad it helped!, be sure to watch the rest of the vids in the playlist!
@SiamakAshrafi
@SiamakAshrafi Жыл бұрын
Best SwiftData tutorial on UTube
@tundsdev
@tundsdev Жыл бұрын
Thanks 🤝
@toastrecon
@toastrecon Жыл бұрын
Looking forward to this!
@tundsdev
@tundsdev Жыл бұрын
Great to hear 👌🏾
@tech_ch1211
@tech_ch1211 Жыл бұрын
You are the best man, really !
@tundsdev
@tundsdev Жыл бұрын
Great to hear, heads up I have an improvement coming soon of this video 👀
@tech_ch1211
@tech_ch1211 Жыл бұрын
@@tundsdev keep up the good work 👍
@dmacharo
@dmacharo 7 ай бұрын
This is a great one! How would you go about hiding the search bar when there are no To-Dos yet? Since the .searchable modifier does not directly support conditional application, would you recommend going with a conditional view structure?
@tundsdev
@tundsdev 7 ай бұрын
Yh its not the best but yh you’d have to do that, also i have a even better filtering video coming out this sunday
@pgong415
@pgong415 Жыл бұрын
Fantastic video you made and great ways to have a searching bar . I have a question: if I accidentally delete the item, how do I restore it , or how do I make a query that filters all deleted items and show them on a view where i can restore the items that i want to ?
@tundsdev
@tundsdev Жыл бұрын
Thanks and if you enable the undo manager I think you can undo changes that you’ve made on your persistant store
@sxmiotb2834
@sxmiotb2834 Жыл бұрын
We’re going places alright thanks to you 🙏 😂 just another great video ❤ Suggestion: vid no.4 Sync the app with iCloud 😬 no pressure. I don’t need it but it’s just a suggestion. 👋
@tundsdev
@tundsdev Жыл бұрын
Thanks 🫂
@enderslee
@enderslee Жыл бұрын
good video! many thinks!
@tundsdev
@tundsdev Жыл бұрын
Glad you liked it!
@대전_1반_양희태
@대전_1반_양희태 6 ай бұрын
best
@kenturnbull9679
@kenturnbull9679 Жыл бұрын
Just noticed that my filteredItems is returning ONLY Items and not Categories as well. Could it be the definition? Too Quick on the comment didn't watch long enough...sorry.
@markaurelius61
@markaurelius61 11 ай бұрын
I was wondering why the list was getting redrawn each time a simple computed property was changing, but it is because searchQuery is declared with @State
@JenniferHolub-g2x
@JenniferHolub-g2x 10 ай бұрын
LOVE your videos!! Can you filter on the Date?? I can not seem to right code for the comparable to give me all items due on one date.
@tundsdev
@tundsdev 10 ай бұрын
You can filter on date, but you have to do a lil bit of a trick which you can see here stackoverflow.com/questions/77143462/how-to-filter-by-current-date-using-swiftdata-and-query
@JenniferHolub-g2x
@JenniferHolub-g2x 10 ай бұрын
Thank you so much for your help and these videos!! Love your stuff!@@tundsdev
@g3dr0cht
@g3dr0cht 9 ай бұрын
Value of type '[IngredientItem]' has no member 'Name' why am i getting this error?
@vanylaskywalker
@vanylaskywalker Жыл бұрын
Could you do a tutorial of download data from a REST API and saving that data into SwiftData?
@tundsdev
@tundsdev Жыл бұрын
It’s coming up very soon 🫡
@paypal7880
@paypal7880 Жыл бұрын
Really good videos buddy! How much do you make on this channel if you don't mind me asking? Is it upwards of $50,000 per year?
@tundsdev
@tundsdev Жыл бұрын
Thanks glad you enjoy it 👌🏾
@mr_shift
@mr_shift 11 ай бұрын
Thanks so much for this series! It's really helpful! Just one thing, between video parts, I'm noticing some continuity issues. For example, at 1:12 I see there's code for .sheet, but I don't have that at all. I double-checked the Github repo and that also has what I have. Where did this new code come from? I've been following each video part very closely and did not see any modification to this part of the code in a prior part. Can you please explain or perhaps point to an updated Github repo? Thanks!
@tundsdev
@tundsdev 11 ай бұрын
Hi thanks, this is part 3 as the title states if you watched the whole series from part 1. You’d see this sheet code for editing a todo 👌🏾
@mr_shift
@mr_shift 11 ай бұрын
@@tundsdev Yes, I started the whole series from part 1 and have the sheet code. However, it's very different from what I have, and I didn't see any changes made to the code in the video.
@w0mblemania
@w0mblemania Жыл бұрын
Firstly, thank for this! Secondly, are you sure this is the right way we should be filtering? As far as I can see -- and feel free to correct -- we are still fetching 100% of the database. And then, we're filtering those (possibly thousands) of entries. If you have, say a diary app, that's going to be a big DB hit after years of use. It seems to me that we need to be filtering at the query level, with a predicate. Regards.
@tundsdev
@tundsdev Жыл бұрын
Hey for a big dataset, i would actually tweak this approach. But for something simple like this it should be fine. I also have an upcoming paid course that will explore efficient queries but this is just something quick and easy. For bigger datasets i.e over 50k records it would be nice in the upcoming betas if Apple released a way to trigger/update the query & sorting kinda like how you can update the sort order with FetchRequest👌🏾
@kenturnbull9679
@kenturnbull9679 Жыл бұрын
This works for one query on the dataset creating the List but how would filteredItems work when you section the list for Active and Completed items? I ended up in a continuous loop. I'm thinking a List to replace the the display of the two sections when searchquery is not empty and a list with the two sections showing when searchQuery is empty.
@tundsdev
@tundsdev Жыл бұрын
I would just have two ForEach’s & have two query macros that use the filter predicate to show completed & uncompleted. Then you can just have two sections 👌🏾
@kenturnbull9679
@kenturnbull9679 Жыл бұрын
@@tundsdev Already have that so I don't use allItems Query, but filteredItems refers ONLY to AllItems(my name) hence my thinking to show a list of the filtered items (1 section) when searchQuery has content and two sections when searchQuery is empty. //MARK: - QUERIES @Query(sort:\ToDoItem.timestamp, order:.reverse) private var allItemsza: [ToDoItem] @Query(filter: #Predicate {!$0.isCompleted}, sort: [SortDescriptor(\ToDoItem.timestamp, order: .reverse)]) var activeToDo: [ToDoItem] @Query(filter: #Predicate {$0.isCompleted}, sort: [SortDescriptor(\ToDoItem.timestamp, order: .reverse)]) var completedToDo: [ToDoItem] var filteredItems: [ToDoItem] { if searchString.isEmpty { return allItemsza } let filteredItems = allItemsza.compactMap { item in let titleContainsQuery = item.title.range( of: searchString, options: .caseInsensitive) != nil return titleContainsQuery ? item : nil } return filteredItems }
@nylelevi750
@nylelevi750 Жыл бұрын
Thanks for the vids man! How would we be able to fetch only items that match today's date?
@tundsdev
@tundsdev Жыл бұрын
Thanks, I cover this in the first vid of this course (link below) that shows you how to filter completed items but essentially you’d use a predicate on filter on the date that is in today Build A To Do List App using SwiftData (Swift Data Tutorials) kzbin.info/aero/PLvUWi5tdh92wZ5_iDMcBpenwTgFNan9T7
@nylelevi750
@nylelevi750 Жыл бұрын
@@tundsdev I followed that but got stuck at the last hurdle 😅 couldn't figure out what to put after '==' I had set a constant called 'today' to Date() and insert this but I kept getting 'Cannot use instance member 'today' within property initializer; property initializers run before 'self' is available' I'm still super noob so not sure what I'm doing wrong
@tundsdev
@tundsdev Жыл бұрын
Hey no worries, so the equal wont work cos that is comparing the actual date to now instead you want to check if a todo item is in today. Here’s a link with examples hopefully this helps 👌🏾 stackoverflow.com/questions/39345101/swift-check-if-a-timestamp-is-yesterday-today-tomorrow-or-x-days-ago
АЗАРТНИК 4 |СЕЗОН 1 Серия
40:47
Inter Production
Рет қаралды 1,4 МЛН
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 60 МЛН
JAVA - How To Design Login And Register Form In Java Netbeans
44:14
1BestCsharp blog
Рет қаралды 10 МЛН
Performing Save and Filter on Enums in SwiftData
23:16
azamsharp
Рет қаралды 1,4 М.
АЗАРТНИК 4 |СЕЗОН 1 Серия
40:47
Inter Production
Рет қаралды 1,4 МЛН