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 trialBecool Man
Courses Plus Student 649 Pointslldb - unwrapping error
let weatherDictionary: NSDictionary = NSJSONSerialization.JSONObjectWithData(dataObject!, options: nil, error: nil) as NSDictionary
Always gives me lldb error without any text.
2 Answers
Stone Preston
42,016 Pointsusing dataObject! means to go ahead and unwrap the optional. basically you are saying you know that its not nil.
dataObject is probably nil so its crashing. post the line of code where you set the value of dataObject
Stone Preston
42,016 Pointsput the ! back and add a print statement after you set the data object so we can see what the value is:
if (error == nil) {
let dataObject = NSData(contentsOfURL: location)
println("dataObject: \(dataObject)")
run it and see if it prints out nil. if its nil there is an issue with the download task
Becool Man
Courses Plus Student 649 PointsIt is still printing just (lldb).
Stone Preston
42,016 Pointsscroll down. there should be more info in the console. can you copy and paste everything htats in the console
Becool Man
Courses Plus Student 649 PointsI think I am just an idiot, nothing else. I've probably hit a breakpoint and Xcode just stop on it :-D
Well, I am still confused with Swift and Xcode (done some work in JAVA past).
Thank you very much, problem solved :-) Now it's printing temperature value.
Becool Man
Courses Plus Student 649 PointsBecool Man
Courses Plus Student 649 PointsIt is not working even without the exclamation mark.
class ViewController: UIViewController {
}