Declaration is only valid at file scope (extension)

后端 未结 1 642
伪装坚强ぢ
伪装坚强ぢ 2021-01-24 06:33

i try to make my app just in portrait mode iam using navigationcontroller i get this error iam usring Xcode7 and Swift 2 And Target System IOS 9.

相关标签:
1条回答
  • 2021-01-24 06:39

    The error message is quite clear. You cannot declare an extension inside of anything - inside a class declaration, inside a struct declaration, etc. It must be outside of everything, at the top level of the containing file. There must be no curly braces around it.

    You have not shown the context in which you are declaring this extension, but clearly there are curly braces around it, or you wouldn't be getting the error!

    But in any case, no matter where you declare them, your extensions are illegal: you can't do an override in an extension. (See my answer here.)

    0 讨论(0)
提交回复
热议问题