Thanks for the response @jakcharvat
I gave it a try, but it doesn't solve the issue.
Actually there is not much more at the moment.
As you can see from the code aboth I have a NavigationView on the initial ContentView and use a NavigationLink to load the AddDeviceView which just uses a List to show the foundDevices array from the GoProManager class.
In the GoProManager I defined a BluetoothDevice as
struct BluetoothDevice: Identifiable {
let id = UUID()
let peripherial: CBPeripheral
}
And hold a list of them in the GoProManger like
class GoProManager : NSObject, CBCentralManagerDelegate, ObservableObject {
@Published var foundDevices: [BluetoothDevice] = [BluetoothDevice]()
[...]
When I press the scan button on the AddDeviceView, the CBCentralManager is looking for devices.
Everytime one is found, a delegate is called in which I add the device to the foundDevices array.
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
let device = BluetoothDevice(peripherial: peripheral)
self.foundDevices.append(device)
}
And everytime this happens the AddDeviceView gets updated, but it is added as a new view to the NavigationView stack I think.