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 Introduction to Table Views Displaying Contact Data Lists of Contacts

Kenan Bateman
Kenan Bateman
16,715 Points

Has bundle path name changed?

I copied Pasan's code in and it's throwing a compiler error on 2 lines in the PListConverter

        guard let path = Bundle.main.path(forResource: name, ofType: type) else {
            throw PlistError.invalidResource
        }

"Use of unresolved identifier Bundle" and

        guard let array = NSArray(contentsOfFile: path) as? [[String: String]] else {
            throw PlistError.parsingFailure
        }

"Use of unresolved identifier NSArray"

Any idea what's up here and what's causing this?

1 Answer

Michael Hulet
Michael Hulet
47,912 Points

My guess is that you forgot to tell Swift that you want to use Apple's framework that all of this is included in. Try putting this at the top of your file:

import Foundation

In Swift, the import keyword says that you want to use some code included in the module you specify. Foundation is one of the core frameworks that Apple built for their OS family, so you'll be using it pretty often on iOS. It's where they define stuff like NSBundle or NSArray, as well as tons of other stuff. Its documentation is available here

Kenan Bateman
Kenan Bateman
16,715 Points

That's it! Careless copy and pasting on my part....