I’m wondering, since array have ordering built in already, why adding ordering property in the first place? Not just persisting the whole array. Is there any cons on default solution? Thanks!
I guess the key thing we have to keep in mind is that all the code here is just a sample created to show some SwiftUI feature and its capabilities. In reality we always have much more complicated stuff and need to handle it in a different way, so here indices is just a simplest value of each element that is easy to understand and track. Keeping indices in objects makes no sense in a real code, I guess.
SwiftData seems to not really care about the ordering of one-to-many relationships, and will happily and unpredictably scramble an array of [SubTasks] that live in Task.subTasks. This seems to especially occur when using CloudKit syncing. I’ve taken to explicitly capturing display order for these related objects, just as Sean does here.
Imagine if you wanted to persist the order in an external data source, so that when the user returns to the app the order remains the same. You would need some property to track the order so you can sort the list by that value on load. I hope I understood what you meant and helped a little with why you would use a property to track the list order number
Great video Sean. Glad I found your content. The other guy who’s content I was learning from is very soft spoken and puts me to sleep. Thanks for not putting me to sleep 😂
I’m currently getting my iOS development certification through my local college. Our instructor wants us to learn storyboards before SwiftUI because he says it’s still commonly used and a bit easier because it’s visual. With that being said can you make some storyboard tutorials as well as describe the logic? Do you already have some storyboard videos on your channel? If so can you link them to me. I love your videos and I’m going to have you to thank when my dreams of becoming an iOS developer come true.
How can we reorder multiple list items by picking them up with the multi-touch gesture using Swift UI? Like in the Photos or Files app or with app icons on the Home Screen?
I really like this concept has anyone display it over a day schedule to then use the on move to to change the time a to do list item is scheduled also how can you allow the user to overlap the items
hey sean. Could you tell me how to change to the trailing closure syntax using only keyboard keys? I'm starting out in Swift and I can't find how to do this. Thanks!
Author is just rewriting the indices saved in the array elements to 0, 1, 2... according to their order in a new array after movements. Another question is why having indices in array elements if array has indices so we need to keep them in sync manually.
Learn more Swift & SwiftUI with my iOS Dev courses at seanallen.teachable.com
I’m wondering, since array have ordering built in already, why adding ordering property in the first place? Not just persisting the whole array. Is there any cons on default solution? Thanks!
I guess the key thing we have to keep in mind is that all the code here is just a sample created to show some SwiftUI feature and its capabilities. In reality we always have much more complicated stuff and need to handle it in a different way, so here indices is just a simplest value of each element that is easy to understand and track. Keeping indices in objects makes no sense in a real code, I guess.
SwiftData seems to not really care about the ordering of one-to-many relationships, and will happily and unpredictably scramble an array of [SubTasks] that live in Task.subTasks. This seems to especially occur when using CloudKit syncing. I’ve taken to explicitly capturing display order for these related objects, just as Sean does here.
Imagine if you wanted to persist the order in an external data source, so that when the user returns to the app the order remains the same. You would need some property to track the order so you can sort the list by that value on load. I hope I understood what you meant and helped a little with why you would use a property to track the list order number
Great video Sean. Glad I found your content. The other guy who’s content I was learning from is very soft spoken and puts me to sleep.
Thanks for not putting me to sleep 😂
Happy to hear it :)
I’m currently getting my iOS development certification through my local college. Our instructor wants us to learn storyboards before SwiftUI because he says it’s still commonly used and a bit easier because it’s visual. With that being said can you make some storyboard tutorials as well as describe the logic? Do you already have some storyboard videos on your channel? If so can you link them to me. I love your videos and I’m going to have you to thank when my dreams of becoming an iOS developer come true.
@seanallen
How can we reorder multiple list items by picking them up with the multi-touch gesture using Swift UI? Like in the Photos or Files app or with app icons on the Home Screen?
Curious to test if this works on watchOS!
I really like this concept has anyone display it over a day schedule to then use the on move to to change the time a to do list item is scheduled also how can you allow the user to overlap the items
This is awesome. Thank you.
Glad you liked it!
hey sean.
Could you tell me how to change to the trailing closure syntax using only keyboard keys?
I'm starting out in Swift and I can't find how to do this.
Thanks!
I was able to recreate option 1 but it doesn't seem to be working when it's in a scrollview. Is there a way to address this issue?
hi I know this is not about video but I can not find a solution how can I use viewDidLoad in swift
How can I reorder sections of items and items inside a section?
This is the first video I've watched by you that I didn't understand. I feel like you could have explained the counter code a bit better.
Author is just rewriting the indices saved in the array elements to 0, 1, 2... according to their order in a new array after movements. Another question is why having indices in array elements if array has indices so we need to keep them in sync manually.
How to update the Swift Data Query after moving the item, with no position property in model
But isn’t Lists ordered already? Why not presist the list it self? 😢
Depends on how you are persisting. Core Data / Swift Data doesn't work like that.
If you want to use onMove but also want to have editActions like delete, is that possible? How would you do that?
you can use the .onDelete(perform: ) modifier
Good to see Allen
Now new apps build with swiftui instead of uikit
New developer focus on swiftui or uikit
What yu thought ?
ok