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

Can't convert value of type URLSessionConfiguration to URLSession

Hey,

I'm trying to connect my app to a database using a tutorial from codewithchris.com Unfortunately, the code there is written in Swift 2, so there are a few errors.

    var session: URLSession!

    let configuration = URLSessionConfiguration.default

    session = URLSession(session: configuration, dataTask: self, didReceiveData: nil)

I'm trying to get this running but it shows up this error at session = URLSession(...)

"Cannot convert value of type URLSessionConfiguration to expected argument type URLSession"

It'd be very great if someone could help me out!

Thanks,

Bruce.

I could be wrong, but if I could remember whenever you type in Swift 2 code it should automatically correct the syntax, or it's in a menu somewhere. I know that when I had all my Swift files (made before Swift 3 and they were all in Swift 2) it just automatically converted them for me into Swift 3 syntax.

I hope this helps!

Yes it autocorrected but the error came after the correction.