Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftUI ForEach 문에서 index 쓰기 #45

Open
chaneeii opened this issue Oct 2, 2022 · 0 comments
Open

SwiftUI ForEach 문에서 index 쓰기 #45

chaneeii opened this issue Oct 2, 2022 · 0 comments
Labels
SwiftUI SwiftUI

Comments

@chaneeii
Copy link
Owner

chaneeii commented Oct 2, 2022

https://gyuios.tistory.com/168

zip 을 사용하자

// topEpisodes.indices
ForEach(Array(zip(topEpisodes.indices, topEpisodes)), id: \.0) { index, item in
    TopEpisodesItem(topEpisode: item, index: index + 1)
}

//topEpisodes.count
ForEach(Array(zip(0..<topEpisodes.count, topEpisodes)), id: \.0) { index, item in
    TopEpisodesItem(topEpisode: item, index: index + 1)
}
@chaneeii chaneeii added the SwiftUI SwiftUI label Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SwiftUI SwiftUI
Projects
None yet
Development

No branches or pull requests

1 participant