The errors show 'Argument passed to call that takes no arguments' for each of the object instantiation in my roomList . The object should instantiate with parameters by default. Can someone helps me on this issue? Thanks in advance.
struct RoomListView: View {
@State private var roomList : [Room] = [
Room(images: "room-1",roomType: "Master Room", ownerID: "1", roomDescription: "@#!@$$", favouritedBy: "1,2", roomPrice: 30, contactPeriod: "Long", currentBookedBy: ""),
Room(images: "room-1",roomType: "Master Room", ownerID: "1", roomDescription: "@#!@$$", favouritedBy: "1,2", roomPrice: 30, contactPeriod: "Long", currentBookedBy: ""),
Room(images: "room-1",roomType: "Master Room", ownerID: "1", roomDescription: "@#!@$$", favouritedBy: "1,2", roomPrice: 30, contactPeriod: "Long", currentBookedBy: ""),
]
var body: some View {
List{
ForEach(roomList){
room in RoomCardView(room: room)
.padding(.top, 10)
.padding(.horizontal, 15)
}
}
}
Models/Room.swift
import Foundation
struct Room: Identifiable {
let id = UUID()
// let id: String
let images: String
let roomType: String
let ownerID: String
let roomDescription: String
let favouritedBy: String
let roomPrice: Float
let contactPeriod: String
let currentBookedBy: String
let updated_at: Double
let created_at: Double
init(images: String, roomType: String, ownerID: String, roomDescription: String, favouritedBy: String, roomPrice: Float, contactPeriod: String, currentBookedBy: String) {
self.images = images
self.roomType = roomType
self.ownerID = ownerID
self.roomDescription = roomDescription
self.favouritedBy = favouritedBy
self.roomPrice = roomPrice
self.contactPeriod = contactPeriod
self.currentBookedBy = currentBookedBy
self.updated_at = Date()
self.created_at = Date()
}
}