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

Getting index when using ForEvery #2242

Open
oreillyjf opened this issue Sep 26, 2024 · 1 comment
Open

Getting index when using ForEvery #2242

oreillyjf opened this issue Sep 26, 2024 · 1 comment

Comments

@oreillyjf
Copy link

Should there be way when using ForEvery (in SwiftIUi) to get index of element?

@maios
Copy link
Contributor

maios commented Nov 5, 2024

It should be the same idea to get the indices to if you use SwiftUI ForEach I believe.

ForEvery(people.indices, id: \.self) { index in
  // Do something
}

Here is an article where we could make use of zip to create a sequence with index and data https://oleb.net/2020/foreach-enumerated/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants