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 trial

iOS Build a Weather App with Swift (Retired) Concurrency Working With JSON

NSJSONSerialization.JSONObjectWithData - compilation error

My piece of code is as follow:

let userCourseDictionary : NSDictionary = NSJSONSerialization.JSONObjectWithData (userCourseData, options: nil, error: nil) as NSDictionary

The error points to the "nil" in options, the parameter. To me it seems that the syntax is exactly the same as in the previous video. (By the way this challenge follows the concurrency session within SWIFT weather app course)

Anyone encounter similar issue?

I'm having the same exact issue. If someone could figure this out it would be greatly appreciated.

5 Answers

Robin Malhotra
Robin Malhotra
14,883 Points

I personally haven't done much of the swift track, but try setting options to something like ''' NSJSONReadingAllowFragments '''

Jacopo Zamboni
Jacopo Zamboni
1,982 Points

Above worked fine for me.

It worked for me. Try it again.

Its broke now with Swift 2.

I retreated from Xcode 7 Beta for now but will need to come back and use the new do {} try syntax since it throws an exception now in Swift 2.0.