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!
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

boris said
3,607 PointsI am still having an error in the project p-list converter class. Please help.
''' class PlistConverter {
class func dictionaryFromFile(resource: String, ofType Type: String) throws -> [String :
AnyObject] {
guard let path = Bundle.main.path(forResource: resource, ofType: Type) else {
throw InventoryError.InvalidResource
}
guard let dictionary = NSDictionary(contentsOfFile: String), let castDictionary =
dictionary as? [String: Any] else {
throw InventoryError.ConversionError
}
return castDictionary
}
} '''
4 Answers

Michael Ayoub
7,689 Pointslet castDictionary = dictionary as? [String:AnyObject] instead of [String: Any] because the function returns castDictionary and it must be of type [String: AnyObject]

boris said
3,607 PointsHmmmm, I made that correction and I'm still getting the same error

Michael Ayoub
7,689 PointsWhat does the error say?

boris said
3,607 PointsCannot convert value of String.Type to expected argument String

Michael Ayoub
7,689 Points(contentsOfFile: path) instead of String

boris said
3,607 PointsThanks, you got it working again