Packix | A Cydia Repository to make Developer 's lives | iOS library
kandi X-RAY | Packix Summary
kandi X-RAY | Packix Summary
A Cydia Repository to make Developer's lives easier
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Packix
Packix Key Features
Packix Examples and Code Snippets
Community Discussions
Trending Discussions on Packix
QUESTION
I'm having a difficult time trying to figure out how to ForEach
loop some array
's of array
's of json data in SwiftUI. I used https://app.quicktype.io to get my data struct from this URL here.
I'm looking to get classes FeaturedHeaderView
and FeaturedPackageView
, which have title's of "Hot Right Now" and "What We're Using" which also contain the FeaturedPackageView
data. My problem is I'm only looping through the first FeaturedHeaderView
and FeaturedPackageView
repeatedly, which I assumed there was two for each section. Is my data struct
incorrect? I've never attempted complex json data yet, so I'm unsure how to handle it properly and if the ForEach
loop is what I'm looking for. The end goal would be to have a List
with `"Hot Right Now" and it's items and then then "What We're Using" and it's items.
I was able to get the FeaturedBannersView
class just fine using two ForEach
loops and thought it would be the same approach for the rest of the data?
The banner view working
...ANSWER
Answered 2021-Feb-20 at 01:37The reason that you're getting the repeats is that you're using .viewClass
and .packageName
as your ids for the ForEach
loops, but in the JSON, those values are not actually unique. FeaturedStackView
, for example, gets repeated.
Add IDs to your models and use them for the ForEach
keys.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Packix
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page