M6L8 implement getTestData Failed to build the scheme

Hello! again trying to learn a little bit more.

This is my screen error:

And de definition of de class and method is:
note: for definition of proyect Bussiness must be a class not struct.

//  Business.swift
//  City Sights App
//  Created by Orlando J on 26-08-23.

import Foundation

class Business: Decodable, Identifiable, ObservableObject {
    @Published var imageData: Data?
    var id: String?
    var alias: String?
    var name: String?
    var imageUrl: String?
    var isClosed: Bool?
    var url: String?
    var reviewCount: Int?
    var categories: [Category]
    var rating: Double?
    var coordinates: Coordinate?
    var transactions: [String]?
    var price: String?
    var location: Location
    var phone: String?
    var displayPhone: String?
    var distance: Double?
    enum CodingKeys: String, CodingKey, Decodable {
        case id
        case alias
        case name
        case imageUrl = "image_url"
        case isClosed = "is_closed"
        case url
        case reviewCount = "review_count"
        case categories
        case rating
        case coordinates
        case transactions
        case price
        case location
        case phone
        case displayPhone = "display_phone"
        case distance
    init(id: String, alias: String, name: String, imageUrl: String, isClosed: Bool, url: String, reviewCount: Int, categories: [Category], rating: Double, coordinates: Coordinate, transactions: [String], price: String, location: Location, phone: String, displayPhone: String, distance: Double) {
        self.id = id
        self.alias = alias
        self.name = name
        self.imageUrl = imageUrl
        self.isClosed = isClosed
        self.url = url
        self.reviewCount = reviewCount
        self.categories = categories
        self.rating = rating
        self.coordinates = coordinates
        self.transactions = transactions
        self.price = price
        self.location = location
        self.phone = phone
        self.displayPhone = displayPhone
        self.distance = distance
    required init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        self.id = try container.decode(String.self, forKey: .id)
        self.alias = try container.decode(String.self, forKey: .alias)
        self.name = try container.decode(String.self, forKey: .name)
        self.imageUrl = try container.decode(String.self, forKey: .imageUrl)
        self.isClosed = try container.decode(Bool.self, forKey: .isClosed)
        self.url = try container.decode(String.self, forKey: .url)
        self.reviewCount = try container.decode(Int.self, forKey: .reviewCount)
        self.categories = try container.decode([Category].self, forKey: .categories)
        self.rating = try container.decode(Double.self, forKey: .rating)
        self.coordinates = try container.decode(Coordinate.self, forKey: .coordinates)
        self.transactions = try container.decode([String].self, forKey: .transactions)
        self.price = try container.decode(String.self, forKey: .price)
        self.location = try container.decode(Location.self, forKey: .location)
        self.phone = try container.decode(String.self, forKey: .phone)
        self.displayPhone = try container.decode(String.self, forKey: .displayPhone)
        self.distance = try container.decode(Double.self, forKey: .distance)
    static func getTestData() -> Business {
                do {
                    let b = try Business(from: <#Decoder#>)
                    b.imageData = Data()
                    b.id = "vhfPni9pci29SEHrN1OtRg"
                    b.alias = "ramen-nagi-palo-alto"
                    b.name = "Ramen Nagi"
                    b.imageUrl = "https://s3-media2.fl.yelpcdn.com/bphoto/GoEjfLMVN4lrGEmv2NapRg/o.jpg"
                    b.isClosed = false
                    b.url = "https://www.yelp.com/biz/ramen-nagi-palo-alto?adjust_creative=dmN8RMaEIO1OimMEwOgzBA&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=dmN8RMaEIO1OimMEwOgzBA"
                    b.reviewCount = 2769
                    b.categories = [Category(alias : "ramen", title : "Ramen"), Category( alias: "noodles", title: "Noodles")]
                    b.rating = 4.5
                    b.coordinates = Coordinate(latitude: Double(37.445523), longitude: Double(-122.1607073261))
                    b.transactions = ["delivery"]
                    b.price = "$$"
                    b.location = Location(address1: "541 Bryant St",address2: "",address3: nil,city: "Palo Alto",zipCode: "94301",country: "US",state: "CA",displayAddress: ["541 Bryant St","Palo Alto, CA 94301"])
                    b.phone = ""
                    b.displayPhone = ""
                    b.distance = Double(5987.3768197170775)
                    return b
                } catch {

if only put let b = Business() in getTestData() the xcode put missing argument:

¿What can i fix it?

It’s because the only initializer you have is the one for decoding.

You should make Business a struct and remove the published property and make a different class for that

All those types are primitive and you don’t need to write a custom decoder for them

Thanks Mikaela!