Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosfreeCodeCamp.org: TimescaleDB Course – PostgreSQL for Time-Series Data(23.09.2026 um 12:30 Uhr)
Windows Tipps & SecurityAndroid 17: Rollout auf Samsung-Galaxy-Smartphones verzögert sich(23.09.2026 um 11:42 Uhr)
Unix & Linux ServerUSN-8733-2: Gzip vulnerabilities(22.09.2026 um 18:04 Uhr)
Sichere ProgrammierungHow to Build Custom PowerPoint Add-Ins for Enterprise Teams(23.09.2026 um 11:25 Uhr)
Sichere ProgrammierungSearch Google Jobs in Real-Time with Go and SerpApi 🚀(23.09.2026 um 12:13 Uhr)
Sichere ProgrammierungA Psychological State is a Coefficient Vector(23.09.2026 um 12:16 Uhr)
YouTube Security VideosfreeCodeCamp.org: TimescaleDB Course – PostgreSQL for Time-Series Data(23.09.2026 um 12:30 Uhr)
Windows Tipps & SecurityAndroid 17: Rollout auf Samsung-Galaxy-Smartphones verzögert sich(23.09.2026 um 11:42 Uhr)
Unix & Linux ServerUSN-8733-2: Gzip vulnerabilities(22.09.2026 um 18:04 Uhr)
Sichere ProgrammierungHow to Build Custom PowerPoint Add-Ins for Enterprise Teams(23.09.2026 um 11:25 Uhr)
Sichere ProgrammierungSearch Google Jobs in Real-Time with Go and SerpApi 🚀(23.09.2026 um 12:13 Uhr)
Sichere ProgrammierungA Psychological State is a Coefficient Vector(23.09.2026 um 12:16 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

[SUI] Combinando List con ForEach

Un List puede pintar un conjunto de vistas (forma estática), uno o más ForEach (forma dinámica) o combinando las dos aproximaciones. A continuación se detalla más sobre cómo combinar List y ForEach para: 1. Crear listas con secci…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Un List puede pintar un conjunto de vistas (forma estática), uno o más ForEach (forma dinámica) o combinando las dos aproximaciones.



A continuación se detalla más sobre cómo combinar List y ForEach para:






1. Crear listas con secciones



En el siguiente ejemplo tenemos dos arreglos anidados. Se crea una lista a partir del arreglo contactGroups, donde cada elemento será una sección (i.e. Section) y dentro de ella, se crea una lista con ForEach para recorrer los elementos de contacts.




struct ContactGroup: Identifiable {
let id = UUID()
let name: String
let contacts: [Contact]
}

struct Contact: Identifiable {
let id = UUID()
let name: String
}

struct ContentView: View {
let contactGroups: [ContactGroup] = [
ContactGroup(
name: "Favoritos",
contacts: [
Contact(name: "Luis"),
Contact(name: "David"),
]),
ContactGroup(
name: "Otros",
contacts: [
Contact(name: "Goyes"),
Contact(name: "Garcés")
]),
]

var body: some View {
List(contactGroups) { group in
Section {
ForEach(group.contacts) {
Text($0.name)
}
} header: {
Text(group.name)
}
}
}
}











2. Crear una lista con componentes estáticos y dinámicos



En el siguiente ejemplo se pintan algunos componentes de forma estática (i.e. el primer Text, seguido de un HStack y un Toggle) y después se crea una sección para agregar una parte dinámica que usa un ForEach.




struct ContentView: View {
let favoritos = [
Contact(name: "Luis"),
Contact(name: "David"),
]

let otrosContactos = [
Contact(name: "Goyes"),
Contact(name: "Garces")
]

@State var otherContactsVisible = true

var body: some View {
List {
Text("Favoritos")

HStack {
ForEach(favoritos) { contact in
Button(contact.name) {

}
.buttonStyle(.bordered)
}
}

Toggle("Mostrar otros contactos", isOn: $otherContactsVisible)

if otherContactsVisible {
Section {
ForEach(otrosContactos) { contact in
Text(contact.name)
}
}
}
}
}
}






Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten [SUI] Combinando List con ForEach

Thematisch verwandte Begriffe: Combinando, List, ForEach · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-96258 | A vulnerability has been found in onSite internet GmbH Auktion NG Auktio…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick