Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Keir Little
Keir Little
4,890 Points

FoodVendingMachine does not conform to protocol

Hi,

Currently working on the Vending Machine App and I'm struggling to get a protocol to conform.

Error message comes up Use of unresolved identifier FoodVendingMachine, also the self.vendingMachine part of the code does not appear in blue text like in the tutorial.

Here is a snippet of the code.

let vendingMachine: VendingMachine

required init?(coder aDecoder: NSCoder) {
    do {
        let dictionary = try PlistConverter.dictionary(fromFile: "VendingInventory", ofType: "plist")
        let inventory = try InventoryUnarchiver.vendingInventory(fromDictionary: dictionary)
        self.vendingMachine = FoodVendingMachine(inventory: inventory)
    } catch let error {
        fatalError("\(error)")
    }

    super.init(coder: aDecoder)
}

Snippet linking to VendingMachine protocol in the main code.

protocol VendingMachine { var selection: [VendingSelection] { get } var inventory: [VendingSelection: VendingItem] { get set } var amountDeposited: Double { get set }

init(inventory: [VendingSelection: VendingItem])
func vend(_ quantity: Int, _ Selection: VendingSelection) throws
func deposit(_ amount: Double)

}

Any help would be appreciated in resolving this.

Regards

Keir