HomeiOS DevelopmentLacking argument for parameter 'time' in name error when working program

Lacking argument for parameter ‘time’ in name error when working program


I’m making this remedy app for a venture and it retains giving these errors 3 occasions subsequent to the app whereas I run it could possibly somebody assist me please.

! THIS IS THE .swift file above the content material view



import SwiftUI

struct DEMOAApp: App {
    let sampleMedicines: [Medicine] = [
        Medicine(name: "Aspirin", dosage: "1 tablet", schedule: "Morning", purpose: "Pain relief"),
        Medicine(name: "Ibuprofen", dosage: "1 tablet", schedule: "Afternoon", purpose: "Anti-inflammatory"),
        Medicine(name: "Acetaminophen", dosage: "1 tablet", schedule: "Evening", purpose: "Fever reducer")
    ]

    var physique: some Scene {
        WindowGroup {
            ContentView(medicines: sampleMedicines)
        }
    }
}

THIS IS THE CONTENT VIEW FILE

import SwiftUI

struct Medication: Identifiable {
    var id = UUID()
    var title: String
    var dosage: String
    var schedule: String
    var goal: String
    var time: Date // Added time property
    
    // Methodology to verify if the medication is scheduled for a selected day
    func timeIsOnDay(_ dayIndex: Int) -> Bool {
        let calendar = Calendar.present
        let medicationDay = calendar.part(.weekday, from: time) - 1 // Alter for 0-based indexing
        return dayIndex == medicationDay
    }
}

// Pattern knowledge for testing
let sampleMedicines: [Medicine] = [
    Medicine(name: "Aspirin", dosage: "1 tablet", schedule: "Morning", purpose: "Pain relief", time: Date()),
    Medicine(name: "Ibuprofen", dosage: "1 tablet", schedule: "Afternoon", purpose: "Anti-inflammatory", time: Date()),
    Medicine(name: "Acetaminophen", dosage: "1 tablet", schedule: "Evening", purpose: "Fever reducer", time: Date())
]

struct ContentView: View {
    var medicines: [Medicine]

    var physique: some View {
        NavigationView {
            Record(medicines, id: .id) { drugs in
                NavigationLink(vacation spot: MedicineDetailView(drugs: drugs)) {
                    VStack(alignment: .main) {
                        Textual content(drugs.title)
                            .font(.headline)
                        Textual content("Dosage: (drugs.dosage)")
                        Textual content("Schedule: (drugs.schedule)")
                        Textual content("Goal: (drugs.goal)")
                    }
                }
            }
            .navigationTitle("Medicines")
        }
    }
}

struct MedicineDetailView: View {
    let drugs: Medication

    var physique: some View {
        VStack(alignment: .main) {
            Textual content(drugs.title)
                .font(.title)
            Textual content("Dosage: (drugs.dosage)")
            Textual content("Schedule: (drugs.schedule)")
            Textual content("Goal: (drugs.goal)")
        }
        .padding()
        .navigationTitle(drugs.title)
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView(medicines: sampleMedicines)
    }
}

I attempted to maneuver the code round and tried many suggestions and tips discovered on-line. They didn’t work

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments