Darin Wilson
Darin Wilson

Reputation: 169

Declaration is on valid at file scope (UI color extension)

Okay so I have an error with my extension, which whenever I add a line or space it up it creates more errors with the UIColor. I can use the Clean function to get it back down to these two errors. My extension is not in {} and I think I have all my blocks closed, but maybe not. It was working fine before I made 'FIRAuth Create User' function if that has anything to do with it. Issue Navigator + the Code

extension UIColor{

    convenience init (r: CGFloat, g: CGFloat, b: CGFloat) {
        self.init(red: r/255, green: g/255, blue: b/255, alpha: 1)
    }

}

Upvotes: 0

Views: 253

Answers (1)

Tim
Tim

Reputation: 60110

Is a previous block perhaps missing a close curly brace? If a preceding class or extension is still open, then this extension isn't at file scope – it's one level deeper, which is invalid. I'd double-check that all of your preceding scopes are closed as you expect.

Upvotes: 1

Related Questions