Hello
Thanks for your answer.
I did a feedback, I will report a bug then.
Post
Replies
Boosts
Views
Activity
Bug reported : FB13714612
Yes it works with this focusfield.
I got no feedback for your information.
Finally, I found where the issue was :
Section(header: Text("Without Genre")) {
ForEach (songs){song in
if let songGenres = song.genres { // <-- PB is here !
if songGenres.isEmpty{
NavigationLink {
SongView(song: song)
} label: {
Text(song.text)
}
}
}
}
.onDelete { indexSet in
indexSet.forEach { index in
let song = songs[index]
modelContext.delete(song)
}
}
}
Then I decided to bypass by calling a function to get the song's genre.
Section(header: Text("Without Genre")) {
ForEach (songs){song in
let songGenres = getGenres(song) { // Change has been made
if songGenres.isEmpty{
NavigationLink {
SongView(song: song)
} label: {
Text(song.text)
}
}
}
}
.onDelete { indexSet in
indexSet.forEach { index in
let song = songs[index]
modelContext.delete(song)
}
}
}
And the func :
func getGenres(song: Song) -> [Genre] {
if let genres = song.genres {
return genres
} else {
return []
}
}