I have the same problem with my array of objects. I can create my view using the index of zero - array[0] - and it responds to the databinding appropriately. If I wrap it with a ForEach but do not change the index of zero to an iterator - array[0] NOT array[index], it still creates the view, but now the data binding does not work. Same exact code, just wrapped in a ForEach loop that should only loop once (the array only has one object inside). What does the ForEach loop do that breaks databinding?// Does data bind correctly
if(self.noise.twoControlEffects[0].isDisplayed){
TwoControlTemplate(title: "Low Pass Filter",
isBypassed: self.$noise.twoControlEffects[0].isBypassed,
knobModel1: self.$noise.twoControlEffects[0].control1,
knobModel2: self.$noise.twoControlEffects[0].control2)
}
// Does not data bind correctly
ForEach(noise.twoControlEffects.indices){ index in
if(self.noise.twoControlEffects[0].isDisplayed){
TwoControlTemplate(title: "Low Pass Filter",
isBypassed: self.$noise.twoControlEffects[0].isBypassed,
knobModel1: self.$noise.twoControlEffects[0].control1,
knobModel2: self.$noise.twoControlEffects[0].control2)
}
}I tried it with array[index] as well, but then did the above once it was not working.// Does not data bind correctly
ForEach(noise.twoControlEffects.indices){ index in
if(self.noise.twoControlEffects[index].isDisplayed){
Spacer()
TwoControlTemplate(title: "Low Pass Filter",
isBypassed: self.$noise.twoControlEffects[index].isBypassed,
knobModel1: self.$noise.twoControlEffects[index].control1,
knobModel2: self.$noise.twoControlEffects[index].control2)
}
}UPDATE - I found a simple solution that worked for me. It may work for you too.See my post:https://forums.developer.apple.com/thread/131577
Post
Replies
Boosts
Views
Activity
WOW thanks for this. Wrapping the code inside my ForEach loop in a VStack fixes my data binding issue discribed here:https://forums.developer.apple.com/thread/131577andhttps://forums.developer.apple.com/message/415107#415107
UPDATE - right after posting this I found a solution (See adding HStack comments at the end of discussion):https://forums.developer.apple.com/message/412141#412141So, this code works and I have no idea why:ForEach(noise.twoControlEffects.indices){ i in
VStack{
if(self.noise.twoControlEffects[i].isDisplayed){
TwoControlTemplate(title: "Low Pass Filter",
isBypassed: self.$noise.twoControlEffects[i].isBypassed,
knobModel1: self.$noise.twoControlEffects[i].control1,
knobModel2: self.$noise.twoControlEffects[i].control2)
}
}
}Apparently, you just have to wrap the inside of your ForEach code in a HStack or VStack.
We are seeing the same throwing -10878 with AVFoundation:
https://developer.apple.com/forums/thread/692264
With your sample code, you can just change the connect line to the one in this stackoverflow answer: https://stackoverflow.com/questions/69414839/in-ios-15-throwing-10878-occurs-many-times-when-connecting-avaudioplayernode
HOWEVER, I am seeing the same "throwing -10878" show up when simply attaching a mixer to the audio engine:
audioEngine = AVAudioEngine()
mixer = AVAudioMixerNode()
audioEngine.attach(mixer) // <-- throwing -10878 occurs here
Same issue for me on all browsers I have tested.