Sorry , I am back
I still don’t understand why ContentView can’t see the func CalculsIL ligne 39 in the File
//
// ContentView.swift
// New
//
// Created by Christophe NOBER on 17/02/2022.
//
import SwiftUI
struct ContentView: View {
@State var indexView1 = 15
@State var indexView2 = 20
@State var indexView3 = 3
var body: some View {
VStack {
LazyHStack {
Spacer()
PickerUIView(index: $indexView1, List: Diaphs, Titre: "Aperture" )
.frame(width: 70.0, height: 300.0)
.clipped()
Spacer()
PickerUIView(index: $indexView2, List: Vitesses, Titre: "Speed" )
.frame(width: 70.0, height: 300.0).clipped()
Spacer()
PickerUIView(index: $indexView3, List: ISOs, Titre: "Iso" ).frame(width: 70.0, height: 300.0).clipped()
Spacer()
}
Text( "IL :\(CalculsIL(ListD: <#T##Diaphs#>, Int: <#T##indexView1#>, ListV: <#T##Vitesses#>, Int: <#T##indexView2#>, ListI: <#T##ISOs#>, Int: <#T##indexView3#>))")
Text (" Ici résultat soon ")
Spacer()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
and in the File func CalculsIL ligne 65 can’t see all arguments ( the indexes with are in the Content View and variables with are declared in the same File between lignes 10and 15 //
// File.swift
// new
//
// Created by Christophe NOBER on 18/02/2022.
//
import Foundation
let Diaphs: [String] = ["0.95","1.0", "1.2","1.4","1.6","1.8","2.0","2.2","2.5","2.8","3.2","3.6","4.0","4.5","5.0","5.6","6.4","7.1","8.0","9.0","10.0","11.0","13.0","14.0","16.0","18.0","20.0","22.0","26.0","29.0","32.0"]
let Vitesses: [String] = ["1/32000","1/16000","1/12800", "1/10000","1/8000","1/6400","1/5000","1/4000","1/3200","1/2500","1/2000","1/1600","1/1250","1/1000", "1/800","1/640","1/500","1/400","1/320", "1/250","1/200","1/160","1/125","1/100", "1/80","1/60","1/50","1/40", "1/30","1/25","1/20","1/15","1/13","1/10" ,"1/8","1/6","1/5","1/4","1/3","1/2.5","1/2","1/1.6", "1/1.3","1","1.3","1.5","2","2.5","3","4","5","6.5","8","10","13","15","20","25","30","40","50","60"]
let ISOs: [String] = [ "12" ,"25", "50", "64", "100", "160","200","250","300","320","400","500","640","800","1000","1250","1600","2000","2500","3200","4000","5000","6400","8000","10000","12800","25600" ]
class Program: ObservableObject {
func ExtractDouble (Value: String ) -> Double
{
// print (Value)
let components = Value.components(separatedBy: "/")
if components.count == 2 {
let x = Double(components[0])! / Double(components[1])!
return (x)
}
else {
let x = Double(components[0])!
return (x)
}
}
func NearestValue ( Value : Double , Liste : [String]) -> String {
var BestCoef = 9999.9
var BestDisp = "None"
for Item in Liste {
// print ( "BestCoef \(BestCoef)")
let z: Double = ExtractDouble (Value: Item)
// print ( abs( 1-Value/z))
if BestCoef > abs( 1-Value/z)
{
BestCoef = abs( 1-Value/z)
// print ( "BestCoef2 \(BestCoef)")
BestDisp = Item
//print (" Nearest: \(Item)")
}
}
if BestCoef >= 1.3 {
BestDisp = BestDisp + "-*" }
else { BestDisp = BestDisp + "-" }
return BestDisp
}
func CalculsIL ( ListD: Diaphs , indexD : indexView1 , ListV: Vitesses , indexD: indexView2 , ListI: ISOs , indexI: indexView3 ) -> Double {
}
}
Still didn’t put any code in CalculsIL as parameters are not “in the scope”
what am I going through ?
Pleeeeeeease help