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



So I'm getting an error if I don't put () after NSURL for the constant queryURL. The error is "Expected member name or constructor call after type name". I'm using Xcode 7.2.1, Swift 2.0

import Foundation

class NetworkOperation {

    lazy var config: NSURLSessionConfiguration = NSURLSessionConfiguration.defaultSessionConfiguration()
    lazy var session: NSURLSession = NSURLSession(configuration: self.config)
    let queryURL = NSURL() // If I don't use () after NSURL here I get error

    init(url: NSURL) {
        self.queryURL = url


1 Answer

Steven Deutsch
Steven Deutsch
21,046 Points

Hey JP Tomberlin,

You are getting that error because you have to initialize the variable with a value when using the assignment operator. When you write NSURL() you are constructing an instance of NSURL and assigning it to that variable.

If you don't want to assign an instance, you use a semicolon and declare NSURL as the type of that variable.

let queryURL: NSURL

I'm guessing this is what you wanted to do because you have queryURL defined as a constant. This means once you initialize it the value cannot be mutated again. Therefore, the initializer you are creating under it would never be able to be used.

Good Luck