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 trialMartin Franzner
3,300 PointsCannot invoke 'pathForResource' with an argument list of type '(String, ofType String)'
if let plistPath = NSBundle.mainBundle().pathForResource("CurrentWeather", ofType: "plist"),
let weatherDictionary = NSDictionary(contentsOfFile: plistPath),
let currentWeatherDictionary = weatherDictionary["currently"] as? [String: AnyObject] {
let currentWeather = CurrentWeather(weatherDictionary: currentWeatherDictionary)
}
It was working perfect, then I actualised my Xcode to version 7.3 an says that thing: Cannot invoke 'pathForResource' with an argument list of type '(String, ofType String)'
I searched on google and some people say that pathForResource was introduced a long time ago, its better to use URLForResource... But its not gonna work if use that, someone can help me?
Jhoan Arango
14,575 PointsHey Martin:
Would you mind posting screenshot of the project and where the error is showing ?
I downloaded the project, added your code, and it's not giving me any errors, perhaps the error is somewhere else ?
Steve Hunter Thank you for the kind words lol.. You've been lost, see ya in slack ?
Steve Hunter
57,712 PointsI've been mega-busy, Jhoan Arango - things are making more sense now so I'll be back in Slack at some point, I'm sure. Deploying Rails applications has proven a bit like hard work! All good fun, though.
Martin Franzner
3,300 Pointsif let plistPath = NSBundle.mainBundle().pathForResource("CurrentWeather", ofType: "plist"),
the error is here, it says that thing: "Cannot invoke...."
For me was working perfect also, but after Xcode upgraded to 7.3, it crashes...
Jhoan Arango
14,575 PointsMartin:
In order for you to be able to post screenshots on here, you first have to upload the picture into a web to host it, then add the link here by following the Markdown Cheatsheet tips.
- You can use this website to host your picture.
Jhoan Arango
14,575 PointsOk, let's do something else..
Try to post the entire code on here, not just the plistPath.. but the whole thing.
Martin Franzner
3,300 Pointsthe link is here
Martin Franzner
3,300 PointsAfter the cleaning it worked perfect! Thank you so much Jhoan! Just for learning, do you have any idea why was crashing before I cleaned?
Thank you again!!
Jhoan Arango
14,575 PointsPerhaps when you downloaded the new version of Xcode, it didn't load the project properly. At this point who knows what could of happened.
Glad you got it resolved. I will change the comment that gave you the fix into an answer, for other students who may have the same issue so they are able to find a solution as well.
Good luck
1 Answer
Jhoan Arango
14,575 PointsMartin:
I do not see any errors, I am using the latest version of Xcode, and Swift and OS, and nothing comes up.
Try cleaning the project.
And then on the same menu, hit "build".
See what that does.
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsI'd ask Jhoan Arango - he's pretty good at iOS stuff! Looks like the updated Swift version is using stronger types than before.