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 Simple iPhone App with Swift Improving Our User Interface Adding a Pop of Color

Robert Kaltenbach
Robert Kaltenbach
10,285 Points

Simulator crash with many exceptions after adding ColorWheel (SOLVED)

SOLVED

Alright, this is a doozy and I'm totally stumped. I've rewatched the video several times and I get the same result each time.

After adding the ColorWheel.swift and adding the additional line of code to the ViewController.swift, when I run the simulator and click the button it crashes, citing the last line of code prior to the curly braces in ViewController.swift.

My initial thought was that I made a mistake with ColorWheel.swift, but I used the same line of code in the viewDidLoad section and I was able to make the color wheel code randomly choose a color on start up.. but it still fails when I hit the button. Even if I comment out ALL of the code related to the button itself with the exception of the @IBAction itself (which previously functioned fine), the simulator still crashes.

Thanks in advance. The following is a lldb bt dump.

(lldb) bt
* thread #1: tid = 0x3001, 0x0008784a FunFacts`ViewController.showFunFact(self=0x7a8506a0) -> () + 10 at ViewController.swift:33, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
  * frame #0: 0x0008784a FunFacts`ViewController.showFunFact(self=0x7a8506a0) -> () + 10 at ViewController.swift:33
    frame #1: 0x00087872 FunFacts`@objc ViewController.showFunFact() -> () + 34 at ViewController.swift:0
    frame #2: 0x01f9f0b5 libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
    frame #3: 0x00a66e38 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 118
    frame #4: 0x00a66db7 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
    frame #5: 0x00c0af3b UIKit`-[UIControl sendAction:to:forEvent:] + 79
    frame #6: 0x00c0b2d4 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 433
    frame #7: 0x00c0a2c1 UIKit`-[UIControl touchesEnded:withEvent:] + 714
    frame #8: 0x00ae752e UIKit`-[UIWindow _sendTouchesForEvent:] + 1095
    frame #9: 0x00ae85cc UIKit`-[UIWindow sendEvent:] + 1159
    frame #10: 0x00a89be8 UIKit`-[UIApplication sendEvent:] + 266
    frame #11: 0x00a5e769 UIKit`_UIApplicationHandleEventQueue + 7795
    frame #12: 0x00188e5f CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    frame #13: 0x0017eaeb CoreFoundation`__CFRunLoopDoSources0 + 523
    frame #14: 0x0017df08 CoreFoundation`__CFRunLoopRun + 1032
    frame #15: 0x0017d846 CoreFoundation`CFRunLoopRunSpecific + 470
    frame #16: 0x0017d65b CoreFoundation`CFRunLoopRunInMode + 123
    frame #17: 0x0474c664 GraphicsServices`GSEventRunModal + 192
    frame #18: 0x0474c4a1 GraphicsServices`GSEventRun + 104
    frame #19: 0x00a64eb9 UIKit`UIApplicationMain + 160
    frame #20: 0x00088781 FunFacts`main + 145 at AppDelegate.swift:12
    frame #21: 0x029a1a25 libdyld.dylib`start + 1
(lldb)
Robert Kaltenbach
Robert Kaltenbach
10,285 Points

Feeling kind of silly, but since I fixed it I figured I'd give my solution:

When I encountered the initial error, I decided to re-apply the connection between my object and my code. I did a lot of debugging and could not solve the error. I made changes to a lot of things and almost gave up. I eventually re-checked to ensure there was only one connection between my button and the code.. and there was two. Throwing up an error.

Removed duplicate connection and thus- the bug.