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 Build a Vending Machine App in Swift 2.0 Loading Data From a Resource Finishing Touches

InvalidType: Fatal Error

I'm getting an invalid type error when I run my code. I'm not sure of what is causing this. In the debugger, it says error = (VendingMachine.inventoryError) invalidType Thread 1: EXC_BAD_INSTRUCTION(code = EXC_1386_INVOP, subcode = 0x0) can anyone help me out :) Thanks

Edit: Heres my code

required init?(coder aDecoder: NSCoder) { do{ let dictionary = try PlistConverter.dictionaryFromFile("VendingInventory", ofType: "plist") let inventory = try InventoryUnarchiver.vendingInventoryFromDictionary(dictionary)

        self.vendingMachine = VendingMachine(inventory: inventory)

    }catch let errror{
        fatalError("\(errror)")
    }

    super.init(coder: aDecoder)

}

2 Answers

oh my goodness! I can't believe my error was because I mistakenly named my enum cases "Poptart" instead of "PopTart". I Spent hours looking for this, but i'm happy now. lol, thanks

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

You dont post code so going by your first error: (VendingMachine.inventoryError) invalidType are you declaring this correctly?

yes I am. It says fatal error: InvalidType: file /Users/admin/Developer/VendingMachineStarterFiles/VendingMachine/ViewController.swift, line 31

this is line 31 catch let errror{ fatalError("(errror)") }