YannickHelmut
YannickHelmut

Reputation: 555

alamofire throws "expected declaration" error

I downloaded the latest versions of xcode and alamofire to create a simple app... unfortunately it seems impossible to send out a request !

Every time I try to build the project, xcode sends me a "expected declaration" error which I don't understand.

Any ideas ? I googled for hours and couldn't find any helpful posts...

Upvotes: 0

Views: 1015

Answers (1)

Tony
Tony

Reputation: 433

If Xcode sends you a "expected declaration" error message, you probably located Alamofire part in class declaration area.

Solution: Move Alamofire part inside some method. like viewDidLoad method.

Example:

class MyView : UIViewController {

    // Not here 
    // Alamofire.request( ... 

    override func viewDidLoad() {
        super.viewDidLoad()

        // Here
        Alamofire.request( ... 
    }
}

Upvotes: 2

Related Questions