SwiftData Background Tasks: Massively Improve Your Apps Performance | SwiftData Tutorial | #12

  Рет қаралды 2,908

tundsdev

tundsdev

Күн бұрын

Пікірлер: 25
@keegan8176
@keegan8176 Ай бұрын
Thank you 🙌 do you have any videos on how to query it not on the main thread like you mentioned at the end?
@rafaelplinio6527
@rafaelplinio6527 9 ай бұрын
Nice video as always and yes... tutorial about Profile in Instruments!
@tundsdev
@tundsdev 9 ай бұрын
You got it!
@SkoroVideo
@SkoroVideo 9 ай бұрын
Awesome video, thanks! YES! I'd really love to see a tutorial about instruments
@tundsdev
@tundsdev 9 ай бұрын
You got it!
@chezchezchezchez
@chezchezchezchez 9 ай бұрын
Yes! A video 2:50 with that tool with be great.
@tundsdev
@tundsdev 9 ай бұрын
I got you!!!
@spaceman2000-i3s
@spaceman2000-i3s 3 ай бұрын
Excellent video on ModelActor macro. It was very helpful.
@tundsdev
@tundsdev 3 ай бұрын
Glad it was helpful!
@chezchezchezchez
@chezchezchezchez 9 ай бұрын
Can you expand on the "Write a predicate to fetch data" (to avoid the @Query on the main thread) My app uses a LOT of @Querys and the main thread is bogged down! I need more speed. Thanks!
@tundsdev
@tundsdev 9 ай бұрын
So you can use something like this www.hackingwithswift.com/quick-start/swiftdata/how-to-create-a-custom-fetchdescriptor The only downside is that you'd have to manage refreshing the view yourself etc which the query macro does for you automatically.
@chezchezchezchez
@chezchezchezchez 9 ай бұрын
@@tundsdev so what do you recommend? I’m only a part-time Programmer/hobbyist. I would prefer something simplistic.
@sergiovinhal5934
@sergiovinhal5934 3 ай бұрын
Helpful. Thank you sir !
@jayelevy
@jayelevy 9 ай бұрын
great video, as always. +1 on a video on instruments!! I have a swift data project that is really bogging down when initiating a view that includes a dynamic filter predicate. I have no idea how to troubleshoot. thanks for what you do
@tundsdev
@tundsdev 9 ай бұрын
Sounds great!
@silky000
@silky000 9 ай бұрын
Yes instruments tutorial!
@tundsdev
@tundsdev 9 ай бұрын
Got it!
@AdelUI
@AdelUI 4 ай бұрын
Thanx for amazing video, but is it working also when i want to update data ?
@ammarahmad9004
@ammarahmad9004 6 ай бұрын
When you set "Strict Concurrency Check" to "Complete", you will get a warning the message "Non-sendable type returned by call to actor-isolated function cannot cross actor boundary", How can void this.
@tundsdev
@tundsdev 6 ай бұрын
You need to make your model sendable manually by marking it with the @unchecked Sendable pretty good article explaining it here but it's safe to use this since we don't modify the model across different threads.Here's a simple example below. @Model class MyModel: @unchecked Sendable { }
@ammarahmad9004
@ammarahmad9004 6 ай бұрын
@@tundsdev Thanks for the explanation.
@spaceman2000-i3s
@spaceman2000-i3s 3 ай бұрын
You can fetch using the ModelActor and then stuff a struct with the results and pass that as the struct is Sendable.
@stevethewindsurfer8911
@stevethewindsurfer8911 3 ай бұрын
Why create an actor who you just reap everything into Task{let modelContext = ModelContext(container) ...} ?
@tundsdev
@tundsdev 3 ай бұрын
You have to use an actor so you can move it off the main thread and isolate it onto it's own thread which is what I explain in the video around 4:20, the ModelActor property wrapper lets you create a context away for the main one
@stevethewindsurfer8911
@stevethewindsurfer8911 3 ай бұрын
@@tundsdev Hmm. In my test this also does move the operation to a background thread. I haven't done much with actors yet, so maybe actors are the preferred way to do it anyway. Here is the code the way I mean it: Task(priority: .background) { let newModelContext = ModelContext(TestApp.sharedModelContainer) (0...1000).forEach { index in let newItem = TestItem(uuid: UUID()) newModelContext.insert(newItem) } try? newModelContext.save() }
How To Use SwiftData with Preview | SwiftData Tutorial | #10
26:16
Car Bubble vs Lamborghini
00:33
Stokes Twins
Рет қаралды 38 МЛН
How Strong is Tin Foil? 💪
00:25
Brianna
Рет қаралды 67 МЛН
REAL MAN 🤣💪🏻
00:35
Kan Andrey
Рет қаралды 42 МЛН
This dad wins Halloween! 🎃💀
01:00
Justin Flom
Рет қаралды 68 МЛН
SwiftData Debugging The Easy Way | SwiftData Tutorial | #11
14:03
Fetch Data from JSON API into SwiftData Database
32:27
azamsharp
Рет қаралды 2,9 М.
SwiftData Migrations | SwiftData Tutorial | #11
32:24
tundsdev
Рет қаралды 4,6 М.
Coding a FULL App with AI (You Won't Believe This)
15:19
Creator Magic
Рет қаралды 146 М.
Car Bubble vs Lamborghini
00:33
Stokes Twins
Рет қаралды 38 МЛН