Hello, well, I am going to tell you about the problem and the "solution" that I have obtained.
A few days ago, because I followed one of Apple's tutorials (https://developer.apple.com/tutorials/app-dev-training/displaying-data-in-a-list), I came up with the idea of simplify my code, I wanted to create a list using cards with CHANGING INFORMATION, and to be able to add or remove data easily. Since I'm new to Swift (I've used more C and Python), I didn't know how to do it, so I followed the tutorial above. I had many problems adding the code and Xcode did not stop complaining and "screaming" 😂, once I changed the code to what you see up there more or less (things are missing and there are many others that the program does not use but, for various reasons, I have not erased 😅), and Xcode did the miracle, it did not complain, there was nothing in red and in Preview it looked just the way I wanted, my pain came, when I connected my iPhone to see the result of my work, and I found a blank app, I built it in the simulator and it also happened the same, there was nothing.
I spent the next few days researching the problem, desperate, tired, and stymied, I wrote on the forum.
I thank the two people who have answered me, their effort and time dedicated to my problem, I really believed that no one was going to appear and I appreciate it very much.
After reading the last answer, I gave up and went back to the backup I made before changing anything, but my stubbornness didn't leave me alone and I removed all the code except a rectangle, foreach, and the data.
IN SUMMARY:
FOREACH DOES NOT ACCEPT DATA THAT CHANGES WITH TIME, YOU GIVE IT A FIXED LIST, A STRING, WITH ALREADY KNOWN DATA AND PROCESSES IT. THE PROBLEM IS THAT IF THE FOREACH FUNCTION IS DESIGNED FOR IMMUTABLE DATA IT SHOULD, AT LEAST, GIVE AN ERROR IF THE DATA IS VAR INSTEAD OF LET, XCODE YELLS AT ME AND PUTS EVERYTHING IN RED, HOWEVER IT COMPILES IT BOTH IN THE SIMULATOR AS IN PREVIEW, WITHOUT IMMUTING. AND IF IT'S A BUG AND NOT DESIGNED FOR THAT, PLEASE, PREVIEW SHOULD NOT WORK. THAT I GOT HAPPY AND THEN I CRY. 🤣🤣
Well that's it, thanks for your patience.
Good afternoon.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: