|
I am currently teaching myself Swift and Swiftui, to that end I am creating an app that is semi useful to me. I have created a peice of functionality that works within the simulator as well as on a physical device but seems to cause a crash in the preview. I have created the following model:
I have a view that lists each instance of an object of this model type and I pass in the instance to a further view so that I can see the full details. so the detail view is is like:
During processing of this view a method is called:
this produces a list of connected too hosts or an empty list (so think device a is connected to switch b which is connected to router c). As I say this works perfectly on a defvice or on the simulator. The issue is coming in when I try to create a preview. I have created the following:
Unfortunately this causes the preview to crash, the pertinent part of the crash report is:
If I remove the while clause in the get_connected_too function the preview will work, but if I either comment out the content of the while or only the while start and end block the preview wil crash. I suspect the issue might be with how I am constructing or providing the test data. Can anyone identfy what I might be doing wrong. |
|
Turns out I have actually just managed to fix it myself. by creating a preview in this way instead:
|
SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.