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

App crashed !!! due to caught exception "NSUnkwonKeyException"

So when I tried to play my finished app (the playlist browsing app) it suddenly crashed straight after, saying : caught exception "NSUnkwonKeyEception",reason [<SimplePlaylist.PlaylistMasterViewController 0x7f9a48578100> set Value : forUndefinedKey : ] this class is not key value coding - compliant for the key playlistImage3. *** First throw call stack : ....

Thread 1 : signal SIGNABRT

Thanks for all help given , really need it.

Hey, could you upload your code? I think I might be able to help out! :)

3 Answers

I think your model class, while loading up the images, one of the value are incorrect. In your error message, I do see the image file "playlistImage3." without its extension. Maybe try placing the image extension (i.e. playlistImage3.png)

Is this the full error message?

This is what pops up after I run the app in the console :

2015-09-10 21:22:14.018 SimplePlaylist[7038:246062] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<SimplePlaylist.PlaylistMasterViewController 0x7fc8a04494a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key playlistImage3.' *** First throw call stack: ( 0 CoreFoundation 0x000000010e387c65 exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010fef2bb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010e3878a9 -[NSException raise] + 9 3 Foundation 0x000000010e7a5b53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259 4 CoreFoundation 0x000000010e2cfd50 -[NSArray makeObjectsPerformSelector:] + 224 5 UIKit 0x000000010eefe4eb -[UINib instantiateWithOwner:options:] + 1506 6 UIKit 0x000000010ed566d8 -[UIViewController _loadViewFromNibNamed:bundle:] + 242 7 UIKit 0x000000010ed56cc8 -[UIViewController loadView] + 109 8 UIKit 0x000000010ed56f39 -[UIViewController loadViewIfRequired] + 75 9 UIKit 0x000000010ed86fdb -[UINavigationController _layoutViewController:] + 44 10 UIKit 0x000000010ed87525 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 216 11 UIKit 0x000000010ed87624 -[UINavigationController _startTransition:fromViewController:toViewController:] + 92 12 UIKit 0x000000010ed88408 -[UINavigationController _startDeferredTransitionIfNeeded:] + 523 13 UIKit 0x000000010ed88ece -[UINavigationController __viewWillLayoutSubviews] + 43 14 UIKit 0x000000010eed36d5 -[UILayoutContainerView layoutSubviews] + 202 15 UIKit 0x000000010eca69eb -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536 16 QuartzCore 0x0000000112a74ed2 -[CALayer layoutSublayers] + 146 17 QuartzCore 0x0000000112a696e6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380 18 QuartzCore 0x0000000112a69556 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 19 QuartzCore 0x00000001129d586e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242 20 QuartzCore 0x00000001129d6a22 _ZN2CA11Transaction6commitEv + 462 21 UIKit 0x000000010ec249ed -[UIApplication _reportMainSceneUpdateFinished:] + 44 22 UIKit 0x000000010ec256b1 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2648 23 UIKit 0x000000010ec24095 -[UIApplication workspaceDidEndTransaction:] + 179 24 FrontBoardServices 0x00000001119ef5e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21 25 CoreFoundation 0x000000010e2bb41c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 12 26 CoreFoundation 0x000000010e2b1165 __CFRunLoopDoBlocks + 341 27 CoreFoundation 0x000000010e2b0947 __CFRunLoopRun + 887 28 CoreFoundation 0x000000010e2b0366 CFRunLoopRunSpecific + 470 29 UIKit 0x000000010ec23b02 -[UIApplication _run] + 413 30 UIKit 0x000000010ec268c0 UIApplicationMain + 1282 31 SimplePlaylist 0x000000010e17a3a7 main + 135 32 libdyld.dylib 0x0000000110628145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

This some of my code in the PlaylistMasterViewController.

import UIKit

class PlaylistMasterViewController: UIViewController {

    var playlistsArray : [UIImageView] = []

    @IBOutlet weak var playlistImageView0: UIImageView!

    @IBOutlet weak var playlistImageView1: UIImageView!

    @IBOutlet weak var playlistImageView2: UIImageView!

    @IBOutlet weak var playlistImageView3: UIImageView!

    @IBOutlet weak var playlistImageView4: UIImageView!

    @IBOutlet weak var playlistImageView5: UIImageView!


    override func viewDidLoad() {
        super.viewDidLoad()
                playlistsArray += [playlistImageView0, playlistImageView1, playlistImageView2, playlistImageView3, playlistImageView4, playlistImageView5]

        for index in 0..<playlistsArray.count {
            let playlist = Playlist(index: index)
            let playlistImageView = playlistsArray[index]

            playlistImageView.image = playlist.icon
            playlistImageView0.backgroundColor = playlist.backgroundColor

        }


        let playlist = Playlist(index: 0)

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()


        // Dispose of any resources that can be recreated.
    }


    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "showPlaylistDetailSegue" {

            let playlistIamgeView = sender!.view as! UIImageView
            if let index = find(playlistsArray, playlistIamgeView) {

            let playlistDetailController = segue.destinationViewController as!
                PlaylistDetailViewController

            playlistDetailController.playlist = Playlist(index: index)


            }

        }


    }


    @IBAction func showPlaylistDetail(sender: AnyObject) {

        performSegueWithIdentifier("showPlaylistDetailSegue", sender: sender)


    }

}

Could you link the project so I can debug it?