Is it the real code ?
You have
Code Block | ForEach(elettori) |
but the array is not declared in this code. Where is it declared and loaded ?
Can you see if it crashes before 45000 ?
Could you add a print(index) during the loading of json file (there may be an error in the json itself) to see where it crashes ?
If you post more code, please use the formatter tool (<>), to produce something like this:
Code Block | struct RisultatiRicercaNominativo: View { |
| |
| @EnvironmentObject var ricerca: Ricerca |
| let elettore: Elettore |
| var ricercaPrecisa :Array = [String]() |
| |
| var ricercaarrey = [Array<Any>]() |
| var body: some View { |
| VStack { |
| navRitorno() |
| .background(Color.blue) |
| |
| List { |
| ForEach(elettori) { item in |
| // CASO NOME PIENO E COGNOME PIENO |
| if ricerca.nome != "" && ricerca.cognome != "" { |
| if String(item.cognome).contains(ricerca.cognome.uppercased()) && String(item.nome).contains(ricerca.nome.uppercased()){ |
| |
| ElettoreSingoloView(elettore: item) |
| .padding(.horizontal, 20) |
| } else { |
| EmptyView() |
| } |
| } //End if |
| |
| // CASO NOME VUOTO E COGNOME PIENO |
| |
| if ricerca.nome == "" && ricerca.cognome != "" { |
| if String(item.cognome).contains(ricerca.cognome.uppercased()) { |
| ElettoreSingoloView(elettore: item) |
| .padding(.horizontal, 20) |
| } else { |
| EmptyView() |
| } |
| } //End if |
| |
| } //END LOOP |
| |
| } //LIST |
| .listStyle(InsetGroupedListStyle()) |
| |
| Button(action: { |
| ricerca.cognome = "" |
| ricerca.nome = "" |
| ricerca.sezione = "" |
| ricerca.indirizzo = "" |
| ricerca.isResult = false |
| }, label: { |
| Image(systemName: "chevron.left") |
| .font(.title) |
| .foregroundColor(.white) |
| }) |
| } |
| } |
| } |