Search code examples
xcodestringvariablesswiftdidset

Swift didSet throwing error


I got the following code:

var languageString: String = "" {
        didSet {
            if(languageString != oldValue) {
                configureView()
            }
            if let popoverController = languagePopoverController {
                popoverController.dismissPopoverAnimated(true)
                languagePopoverController = nil

            }
        }
    }

The error that is shown is:

Computed property must have an explicit type

I don't understand the error. I am a beginner. Any help?

EDIT: More code

@IBOutlet weak var detailDescriptionLabel: UILabel!
@IBOutlet weak var webView: UIWebView!

private var languageButton: UIBarButtonItem?
private var languagePopoverController: UIPopoverController?

The declaration is simple the rest of the code is on a tableView but that is not giving any errors, is just the string

EDIT 2: More code

func configureView() {

    //update the interface for details on the item
    if let detail: AnyObject = self.detailItem {
        if let label = self.detailDescriptionLabel {
            let dict = detail as [String: String]
            //let urlString = dict["url"]!
            let urlString = modifyUrlForLanguage(url: dict["url"]!, language: languageString)
            //detailDescriptionLabel.text = urlString
            label.text = urlString
            let url = NSURL(string: urlString)!
            let request = NSURLRequest(URL: url)
            webView.loadRequest(request)

            let name = dict["name"]!
            title = name
        }
    }

}

Here is the configure view. Maybe it helps.

Xcode error view


Solution

  • Got it, I put an space in the string " " instead of "" I have no idea why but it works.