How you can make dynamic list in your iPhone app | ios | swiftUI |Identifiable |UUID()
A list in SwiftUI is almost similar to tableView , if you want to make it dynamically so that you don’t want to write every item of the list in your list view , you can create an array of your list items and you can fetch them by identifying . Now to get every item from array to the list , you must create your data as identifiable .
To understand it more clearly , go through the below code :
In line 26 you can see we have created a structure of type identifiable and inside it a variable as id of UUID . UUID provides a unique id to every properties . In line 31 we are creating array of post and initialising our element .
In list we are kind of fetching our elements from array posts and showing them in our list .
This is how our app will look like :
MY LINKEDIN : linkedin.com/in/my-pro-file
Topics You May Interested IN
- Protocol : https://levelup.gitconnected.com/protocols-in-swift-7359a88248b4?source=---------8------------------&gi=b985317da979
- Enum : https://levelup.gitconnected.com/enumerations-in-swift-5dd14b4055a7
- Properties : https://medium.com/dev-genius/what-are-properties-in-swift-2ec8aba9a378
- Structure : https://medium.com/@mdcode2021/what-is-structure-in-swift-ebc22767fe1d