How I make order numbers by swiftui

Welcome I'm new to language learning and built an app for food orders But I ran into a problem that I don't know how to add a serial number to each order What is the method or what am I looking for so that I know how to search

for example:

Welcome to the forum.

A first advice: You should show the code, it would be much easier to explain. And explain what you get and what you expect.

.

I don't know how to add a serial number to each order

Could you explain the problem ?

Order numbers are just another property of an object. If you've got some data structure that has, for example, customerName, orderDate, location, then just add an orderNumber field and populate it with whatever number you need to use. I can't tell you what that number should be; it's up to you to decide. Perhaps it's the row id in your database's orders table?

Thank you for your reply

This code: Here the data is uploaded to Firebase

And this is View:

But when you restart the application and add a new restaurant, the counting is done again, starting from zero. I want every restaurant to have its own number

Thanks for feedback. But it is not clear how this code relates to the original post.

In addition, please post the code itself, and complete, not partial screenshots. Line 77 is missing, what is it ?

How is restaurantNumber defined ?

If you want each restaurant to have its own and fixed number, you have to include it in the struct that you save.

But without seeing full code, it is a useless guessing game.

Thank you

Yes, it is related to the original publication because it is the same concept (order number, restaurant code, billing number..etc) Thank you

Yes, it is related to the original publication because it is the same concept (order number, restaurant code, billing number..etc)

What I want is when the restaurant is added to the database, a serial number is attached to it

Model:

View Model

View

How I make order numbers by swiftui
 
 
Q