Jordan H
Jordan H

Reputation: 55675

Swift class init throws compile-time error "expected declaration"

I'm surely missing something very simple here. I've created a custom class and want to provide an init method to set a property on the class - simple. But the init method is throwing a compile-time error: "Expected declaration". I don't see any differences with the latest version of the Swift programming guide. What's wrong here?

import UIKit

class MyClass: NSObject {

    var thumbnailView: UIView

    init​(thumbnailView​: UIView) { //ERROR: Expected declaration
        self.thumbnailView = thumbnailView
    }

}

Upvotes: 1

Views: 2858

Answers (1)

Nate Cook
Nate Cook

Reputation: 93276

I asked BBEdit to zap your gremlins and it gave me back this:

class MyClass: NSObject {

    var thumbnailView: UIView

    init•(thumbnailView•: UIView) { //ERROR: Expected declaration
        self.thumbnailView = thumbnailView
    }

}

Two gremlins!

Upvotes: 4

Related Questions