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...
Topic:
Programming Languages
SubTopic:
Swift
Tags: