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 trialJulien Schmitt
2,334 PointsMissing return in a function
Hi,
I'm getting an error but I don't know why. Copied what was done in the course but I'm getting "Missing return in a function expected to return [String: AnyObject] when the return type is specified. Why?
class PlistConverter {
class func dictionaryFromFile(resource: String, ofType type: String) throws -> [String : AnyObject] {
guard let path = NSBundle.mainBundle().pathForResource(resource, ofType: type) else {
throw InventoryError.InvalidResource
}
guard let dictionary = NSDictionary(contentsOfFile: path),
let castDictionary = dictionary as? [String : AnyObject] else {
throw InventoryError.ConversionError <-- Error here
}
return castDictionary
}
}
Copied what was done in the course but I'm getting an error "Missing return in a function expected to return [String: AnyObject]
when the return type is specified. Why?
Thanks,
Julien
Martin Wildfeuer
Courses Plus Student 11,071 PointsMartin Wildfeuer
Courses Plus Student 11,071 PointsTbh, I cannot see an error in the snippet you posted... Have you tried clearing derived data and the build?