Sorry guys first trime trying to post my own thread
here is the error from compiler
"Closure containing control flow statement cannot be used with result builder 'ViewBuilder"
appear on line 21 " For item in items {"
//
// ContentView.swift
// Project1
//
// Created by Sebastien BENAVIDES on 2/2/24.
//
import SwiftUI
struct ContentView: View {
var pictures = [String]()
var body: some View {
let fm = FileManager.default
let path = Bundle.main.resourcePath!
let items = try! fm.contentsOfDirectory(atPath: path)
for item in items {
if let item = item.hasPrefix("nssl") {
pictures.append(item)
}
}
print(pictures)
}
}
#Preview {
ContentView()
}
I'm trying to follow STORMVIEWS tutorial which was made with an old version of swift were viewed load was still available...
Post
Replies
Boosts
Views
Activity
Could you please update your guidebook : https://developer.apple.com/tutorials/swiftui/handling-user-input here as it's mentioned about observable macro but doesn't say we need to import anything , ive spent over 1h to figure out were my programme was not following. your guidance until I came across this topic and it solves my issues