I study SwiftUI in swift tutorial. In tutorial Apple shows that code:
"List(landmarks,id: \.id){
landmark in
LandmarkRow(landmark: landmark)
}"
Where "landmarks" it is array of Landmark, "id" it is String var in structure "Landmark" . What do parameter "id: \.id"?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi guys! I have one question about .filter.
In tutorial Apple show this code:
@State private var showFavoritesOnly = false }
var body: some View {
NavigationView {
List(filteredLandmarks) { landmark in
NavigationLink(destination: LandmarkDetail(landmark: landmark)) {
LandmarkRow(landmark: landmark)
}
}
.navigationTitle("Landmarks")
}
}
}
How works this "var filteredLandmarks: [Landmark] { landmarks.filter { landmark in
(!showFavoritesOnly || landmark.isFavorite) }}".
If somebody tell me how it works i will be happy