-2

I am using separate class to save objects in the class. But it shows an error: "Return from initializer without initializing all stored properties". Please help me to resolve this.

class FetchedExpectedVisitors
{
    var id: Int
    var name: String
    var email: String
    var phone: String
    var department_id: Int
    var employee_id: Int
    var location_id: Int
    var image: String
    var verification_code: String
    var qr_code: String
    var isVisited: Int
    var company_id: Int
    var purpose: String
    var meeting_date: String
    var meeting_time: String
    var duration: String
    var created_at: String
    var updated_at: String

    init(id: Int, name: String, email: String, phone: String, department_id: Int, employee_id: Int, location_id: Int, image: String, verification_code: String, qr_code: String, isVisited: Int, company_id: Int, purpose: String, meeting_date: String, meeting_time: String, duration: String, created_at: String, updated_at: String) {

        self.id = id
        self.name = name
        self.email = email
        self.phone = phone
        self.department_id = department_id
        self.location_id = location_id
        self.image = image
        self.verification_code = verification_code
        self.qr_code = qr_code
        self.isVisited = isVisited
        self.company_id = company_id
        self.purpose = purpose
        self.meeting_date = meeting_date
        self.meeting_time = meeting_time
        self.duration = duration
        self.created_at = created_at
        self.updated_at = updated_at   
    }   
}
Ayush Agrawal
  • 147
  • 2
  • 2
  • 9
  • You didn't set the `employee_id` in the init method. So the error is saying that in the init, there are stored property (in your case the `employee_id`) that is not initialized. It's present in your method, you just forgot, but if you want to declare other var but not initiliaze them in the init, read this: https://stackoverflow.com/questions/29673488/return-from-initializer-without-initializing-all-stored-properties – Larme Apr 21 '18 at 12:47

1 Answers1

1

Add self.employee_id = employee_id inside init().