Missing bracket??

I have checked this code until I am 'blue in the face', but I can't see why I get an error saying missing closing bracket.
Code Block
//
//  ExploreDataManager.swift
//  LetsEat3
//
//  Created by Tony Hudson on 16/04/2021.
//
import Foundation
class ExploreDataManager {
    func  fetch() {
        for data in loadData() {
        print(data)
    }
}
    fileprivate func loadData() -> [[String: AnyObject]] {
        guard let path = Bundle.main.path(forResource: "ExploreData", ofType: "plist"), let items = NSArray(contentsOfFile: path) else  {
            return [[:]]
        }
        return items as![[String: AnyObject]]
    }
}

If I add an additional bracket it then reports an additional 'Expected '}' in class?
I have counted 5 opening brackets and 5 closing brackets. I even checked to see whether I had mistakenly typed the wrong type of bracket elsewhere in the code!
Is this a bug?
If not what is the reason. for this error?

Replies

The brackets in your code sample match correctly.
I get no error.

Is your error being triggered by some other code, that you have not shared?
Luckily this is an exercise from a book and the files are available online. I copied the file and pasted it in the project and No errors?
Still can't see what caused the error, so if anyone can find why the error occurred please let me know.
Not error with the exact same code.

Did you get the error message in code but did code compile normally ?
If so, that's just a previous error that was not purged (clean build folder let clear all those annoying cached errors).
Unfortunately the only code that was available had some extra func's, so not an exact match. But as I exited the project to retrieve the code, would that have cleared the cache?
Yes, exiting and reopening may clear it.

Anyway, remember the option-clean build folder command any time you have some weird behaviour. It takes no time and may save a lot.

Good continuation, and don't forget to close the thread.