0

Good morning Everyone, I'm building an app that allows to create and add “tables”(rectangles) to a floor plan of a restaurant. I would like to know if there is a way in SwiftUI to save the position of every ”table” that the user creates before and after the user have dragged them across the screen to arrange them as the restaurant disposition.

Thanks in advance!

I tried to use the drag gesture and it's fine the way it works, but once you close the app from the multitasking the shapes return in the center of the screen.

  • Try to save and load the offsets with UserDefault or the AppStorage property wrapper. – Louis Lac Nov 16 '22 at 14:50
  • 1
    While you *could* save the information (number of tables, position for each table, etc) in UserDefaults, that can lead to problems if you end up trying to save a lot of information (I'm guessing you may also have table size, table type *[round, square, etc]*, and maybe additional properties). Better to create a structured data file. Take a look at this tutorial from Apple: [Persisting data](https://developer.apple.com/tutorials/app-dev-training/persisting-data) – DonMag Nov 16 '22 at 16:18

0 Answers0