Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,843 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....