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 Using the Vending Machine Updating the Quantity

Michael Murray
Michael Murray
6,037 Points

HELP! I have a CRASH at Updating Quantity of the Vending Machine App

My code and the error I get:

@IBAction func updateQuantity(sender: UIStepper) { print(sender.value) }

Thread 1: SIGABRT . Generated from the following file:

// AppDelegate.swift // VendingMachine // // Created by Pasan Premaratne on 1/19/16.

2016-08-15 17:19:21.270 VendingMachine[48597:4383104] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<VendingMachine.ViewController 0x7fda9bcb6be0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key updateQuantity.'

Michael Murray
Michael Murray
6,037 Points

Thank you Martin for responding. I have tried several times to remove the code and the storyboard link. Doesn't get rid of the crash . . .y I am thinking of starting the course from the very beginning to make sure that the unknown bug in my code or any unwanted connections are not there. How do I go about doing this?

1 Answer

Martin Wildfeuer
PLUS
Martin Wildfeuer
Courses Plus Student 11,071 Points

This is most commonly the result of a storyboard outlet/action connected to a property/method that is not longer there. That is, you might have removed/renamed a property/method in code that was still connected to an outlet. This is not handled automatically by Xcode, if you remove a connected property/method in code, you also have to remove that connection in storyboard.

To check for this, switch to storyboard and bring up the utilities column (upper right). Select the element and the connections inspector (top right of the utilities column). Check if there are any unwanted connections and remove them if necessary.

In your case, something (I guess a button action) was connected to updateQuantity on your ViewControllerclass, but it seems to be not there anymore.

Hope that helps!

Michael Murray
Michael Murray
6,037 Points

Thank you Martin for responding. I have tried several times to remove the code and the storyboard link. Doesn't get rid of the crash. Is there an order to it - do you remove the code first, then the link (or does it matter)?